My logins() sub routine will continue to carry out both the else and elif parts after it has found a login and has verified the password. I cant seem to understand why its doing this but is really halting my progress. enter image description here
def login ():
Username_Input = input("Please enter your username : ")
logins = open("logins.csv","r")
List_Information = list(csv.reader(logins))
for x in List_Information:# loops through all lists
if x[0] != Username_Input :
print("Username not found please register ")
register ()
else:
Password_Input = input("Username found please enter your password : ")
for x in List_Information:
if x[1] == Password_Input :
print("Loged in lets get this game going. ")
game()
else :
print("nope sorry password not found lets go back to the menu : ")
Menu()
After it has found the correct password it will continue going through the List_information after calling game(). The call to game() would not stop the looping and thus it finds the next user from the List_information and say that the password was wrong.
You should be finding the correct entry from the List_information (based on the username) and the check the password against that entry. Now you are basically only comparing the first element in the List_information.
Something like this:
user = None
for x in List_information:
if x[0] == Username_input:
user = x
if user == None:
print("Username not found please register ")
register ()
else:
Password_Input = input("Username found please enter your password : ")
if user[1] == Password_input:
game()
else:
Menu()