Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save naemazam/9eac86287cfb44babc6ea34399eb7ac9 to your computer and use it in GitHub Desktop.
Save naemazam/9eac86287cfb44babc6ea34399eb7ac9 to your computer and use it in GitHub Desktop.
a simple login system check
''' When logging in the system, the user needs to first enter the account. If the account does not exist, output ”Wrong User"
and end the program; When the account number is correct, enter the password again to verify whether the account password is
consistent with the given account password. If it is consistent, output ”Success", otherwise output ”Fail" and the
remaining attempts. The total number of attempts is 3. If all three attempts are input incorrectly, ”Login Denied" is output.'''
dic={"aaa" : ["123456",10000],"bbb" : ["888888",5000],"ccc" : ["333333",3000]}
user_name=input("Enter User Name: ")
if user_name in dic.keys():
for i in range(3):
pas=input("Enter Password: ")
if pas==dic[user_name][0]:
print("Success")
break
if (i==2):
print("Login Denied")
break
elif (pas != dic[user_name][0]):
print(f"Fail({3-i} attempts left): ")
else:
print("Wrong User")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment