+ 1

How to write a program to input login details and return messages like "login successful","invalid..."&"account blocked"

def login(): uid=input("Username:") pwd=input("Password:") counter=list() if(uid=="ADMINMSBONNIE" and pwd=="Storage1914"): print("Login successful") else: counter.append(1) if(sum(counter)==3): print("Account blocked. You have exceeded your log-in attempts") else: print("Invalid username/password. Please try again") print(sum(counter)) login() login() I've tried this but it's neither printing "account blocked..." in case of 3 incorrect login attempts nor counting the sum of the counter list. Please suggest any modification to this code.

11th May 2021, 8:30 AM
MsBonnie
MsBonnie - avatar
1 ответ
+ 1
Whenever login() function is called on incorrect password and username it reinitializes the counter with an empty list. I would do it something like this , https://code.sololearn.com/cjuVqtKw7tDJ/?ref=app
11th May 2021, 10:20 AM
Abhay
Abhay - avatar