Demand:
1. User Input Password correct login
2. User input password error exit and call function continue input
3. When the user enters a password that matches a given value, allows the user to reset the password and can log in with the new password
Although the paste is simple, but also to record, nonsense not much to say direct code
1 #!/user/bin/env python2 #-*-coding:utf-8-*-3 #Author:qinjiaxi4Password_list = ['[Email protected]#','12345']5 defAccount_login ():6password_input= input ('Please enter your password:')7Password_correct = Password_input = = Password_list[-1]#because the judging condition is too long can be assigned to a variable, so that the code looks neat and clean some8Password_reset = Password_input = =Password_list[0]9 ifPassword_correct:Ten Print('Login success!') One elifPassword_reset: ANew_password = input ('Please enter a new password:') - password_list.append (New_password) - Print('your password has been modified successfully') the Account_login () - Else: - Print('Input Error') - Account_login () +Account_login ()
Python implements login password reset simple operation