The user has to input the correct login information (e.g username = Anna, password = 12345).
When the user's input is correct, the verify_login menu will loop again once. I don't want it to and I don't know how to fix that. Am I not understanding something?
The goal is for the user to input the correct data, and for the login_menu() function to be shown then. Ignore the 'reading.from.user' source code. I've spent a good amount of time on this and it's frustrating.
import reading_from_user
def create_login():
with open ('Login_data.txt', 'w') as a:
a.write('Username = Anna\n'
'Password = 12345')
def verify_login():
username = reading_from_user.read_nonempty_alphabetical_string(">>>>>>> Please enter your username:")
password = reading_from_user.read_nonempty_string(">>>>>>> Please enter your password: ")
if username != 'Anna':
login_again()
elif password != '12345':
login_again()
else:
return username, password
username, password = verify_login() #<--- this should be in the code above
def login_again():
print("Please try to log in again!")
verify_login()
def login_menu():
print('Name:', username)
print('Password: ', password)
def main():
create_login()
verify_login()
login_menu()
main()
Aucun commentaire:
Enregistrer un commentaire