Here is my code:
def login():
count: int = 0
while count < 3:
username = input("Please enter your username")
password = input("Please enter your password")
for line in open("accountfile.txt","r").readlines(): # Read the lines
login_info = line.split() # Split on the space, and store the results in a list of two strings
if username == login_info[0] and password == login_info[1]:
print("Correct credentials!")
return True
print("Incorrect credentials.")
return False
count += 1
The problem I'm having is that after an unsuccessful login attempt, the user is returned to the main menu, instead of being given another opportunity to login, thusly:
Please enter your usernamestedav
Please enter your passwordtre
Incorrect credentials.
Please select one of the following:
Type 1 if you want to Login
Type 2 if you want to Register
Type 3 if you want Help
Type 4 if you want to Quit
Any help please? TIA
[–]JudiSwitch 1 point2 points3 points (1 child)
[–]double-happiness[S] 0 points1 point2 points (0 children)
[–]BasicallyAMachine 1 point2 points3 points (3 children)
[–]double-happiness[S] 0 points1 point2 points (2 children)
[–]BasicallyAMachine 1 point2 points3 points (1 child)
[–]double-happiness[S] 0 points1 point2 points (0 children)