我编写了一段练习代码,要求用户从这个模拟数据库中输入用户名和密码。我的问题是如何使任何给定用户的用户名与密码相关联?所以用户“amy”的密码将是“apple”。我是否只需要一个变量设置作为字典,或者类似的东西?
list= ["amy", "chris", "jake"]
password = ["apple", "orange", "date"]
login = ("")
counter = 0
attempts = 5
out_of_attempts = False
while login not in list and not (out_of_attempts):
if counter < attempts:
login = input ("enter username: ")
counter += 1
else:
out_of_attempts = True
if out_of_attempts:
print ("Sorry login limit exceeded please try again later")
else:
pass
while login not in password and not (out_of_attempts):
if counter < attempts:
login = input ("now password please: ")
counter += 1
else:
out_of_attempts = True
if out_of_attempts:
print ("sorry password limit exceeded, try again later")
else:
print ("thank you please wait")
慕丝7291255
偶然的你
MMMHUHU
相关分类