I have a text file that contains 100 passwords. I want the user to be able to input their password, and have the program check the file. If the password entered matches then the program can end, but if the password does not match I want the to be able to try again.
pwEntry = input("Enter your password: ")
f1 = open('passwords.txt','r')
for line in f1:
if pwEntry in line:
print("success")
else:
print("try again")
f1.close()
I have tried a while loop, but it just says try again every time, even if I put in a correct password so its broken somehow.
f1 = open('passwords.txt','r')
for line in f1:
line = line.rstrip()
pwEntry = 'x'
while pwEntry not in f1.read():
pwEntry = input("Enter your password: ")
if pwEntry in f1.readlines():
print("Success")
else:
print("Try again")