So I made the login program that reads the usernames and password from a file (names.txt).
The program works correctly. But my problem is I want to ask give the user 3 chances to get the username right before the program closes and 10 chances to get the password right before the program closes.
Using loops isn't working. What should I be doing differently?
Here's my program
def main():
file = open("names.txt", 'r')
line = file.readline()
A={}
while line:
s=line.split()
user=s[3]
password=s[4]
A['user']=s[3]
A['password']=s[4]
line = file.readline()
print(A)
name=input("Username: ", )
code=input("Password: ", )
if (name in A['user']) and (code in A['password']):
print("Successful Login")
else:
print("Username or Password Incorrect")
main()