Jul-12-2019, 11:17 AM
Hello everyone!
At the moment I'm working on a simple Regiter/Login project which uses text file to store all the data.
The output:
Please enter your username: Jeff
Found the user in line: 1
123
Username Jeff not found!
DataFile:
Jeff 123
Sandra 753
Mike 482
At the moment I'm working on a simple Regiter/Login project which uses text file to store all the data.
username=input("Please enter your username: ") with open("Data.txt", "r") as DataFile: for i,line in enumerate(DataFile): if username in line: print("Found the user in line:",i) data=line.split() password=data[1] print(password) if username not in DataFile: print("Username ",username," not found!")I get no error messages, but the problem is that both if statements are correct- at the same time username is and not in the file. Any help would be appreciated.
The output:
Please enter your username: Jeff
Found the user in line: 1
123
Username Jeff not found!
DataFile:
Jeff 123
Sandra 753
Mike 482