#模拟登录,依次输入用户名、密码,最多三次机会 userd = ['Linda', '123456'] while 1: username = input("Please input the username:") if username in userd: break else: print("your username is wrong!") count = 3 while 1: password = input("Please input the password:") if userd[1] == password: print("Login success!") break else: print("Your password is wrong, please try again!") count -=1 if count == 0: print("The user is locked") break else: print("You have %d chances left" %count)