def login():
contents = {}
with open("pwdFile.txt") as f:
for line in f:
split = line.split("|")
contents[split[0]]= ",".join(split[1:])
if userName.get() in contents:
print("Username exist")
if contents[userName.get()] == pwd.get():
print("logged in")
print(contents)
print(contents[userName.get()])
print(pwd.get())
This code is reading from a file to check if the stored password in the file matches the password that is inputted.Both passwords are identical however they do not match therefore the if contetns == pwd.get is not executed.I am using tkinter and getting pwd from an Entry() and passing it to the login() function.
Here is the text file its reading from: james|pwd
reprof your strings, which will put quotation marks around them (making whitespace more apparent) and escape any special characters.