The purpose of this task is to check each line in the user.txt file (that contains a list of usernames and passwords)
The program should then compare the input username and password to each line in the txt file if it doesn't find any matching username and password it displays an error message if it does the loop should break
user.txt
Steve steve123
Eddie ed123
Dexter dex123
I tried just about anything I could think of.
Although I'm almost dead certain the problem is in the loop.
It seems that it only compares the last line in the txt file
I'm still pretty new to this so please have mercy :)
Any tips on how I can get the program to check if the user input matches each individual line of text. Also , The txt file can change or be added to at any point , if not I could have accomplished this using line indexing.
content = ""
user_List = []
while True:
print("Username")
username = input()
print("Password")
password = input()
name_pass = username + " " + password
with open("user.txt" , "r+") as f:
for line in f:
if name_pass == line:
x = False
else:
x = True
if x == False:
print("Wellcome")
break
elif x == True:
print("Incorrect Username or Password \nPlease try again")