-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
100 lines (88 loc) · 3.23 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
bd_user = {
"customer@gmail.com": "customer",
"1": "1",
"2": "2"
}
def AddUserToDb():
email = input("email: ")
password = input("password: ")
bd_user[email] = password
print("Вас додали до бази")
def deleting ():
email = input("email: ")
password = input("password: ")
if email in bd_user and bd_user[email] == password:
del bd_user[email]
print ("Ви успішно видалели користувача")
else:
print("такого користувача не існує")
def doctor():
try:
count = 0
while count < 3:
check = False
email = input('email -> ')
password = input('password -> ')
if email in bd_user and bd_user[email] == password:
check = True
if check:
print("Вас авторизовано")
for i,j in bd_user.items():
print (f" email - {i}, password - {j}")
return True
elif count < 2:
print("Повторіть спробу")
else:
print("Вас заблоковано")
return False
count += 1
except:
print('error')
def newpassword():
try:
count=0
while count < 3:
check = False
email = input('email -> ')
password = input('password -> ')
if email in bd_user and bd_user[email] == password:
check = True
if check:
change=input("ви хочете змінити пароль? ")
if change=="так":
newpassword=input("напишіть новий пароль+: ")
bd_user[email] = newpassword
print(" ви оновили свій пароль")
elif change=="ні":
print("гарного дня")
return True
elif count < 2:
print("Повторіть спробу")
else:
print("Вас заблоковано")
return False
count += 1
except:
print("error")
def main():
while True:
print("Якщо ви хочете подивитись всіх користувач, напишіть 1\n" +
"Якщо ви хочете додати користувача, напишіть 2\n" +
"Якщо ви хочете видалити користувача, напишіть 3\n" +
"якщо ви хочете змінити пароль, напишіть 4\n" +
"Якщо ви хочете завершити програму, напишіть 0")
check = int(input())
if check == 0:
print("Гарного дня!")
break
elif check == 1:
doctor()
elif check == 2:
AddUserToDb()
elif check == 3:
deleting()
elif check == 4:
newpassword()
else:
print("Оберіть ще раз")
main()