0

Im new to programming python3 and i'm trying to write a password program. i want to compare a word from a .txt file with a input. no matter if i type the password in write or wrong it always comes up 'access denied!'

inFile = open('passwordtest.txt', 'r')
password = inFile.read()
userguess = input("Enter password: ")
if password == userguess:
    print('Access Granted!')
else:
    print('Access Denied!')
    input()

Thank you in advanced!!

2
Contributors
3
Replies
51
Views
3 Years
Discussion Span
Last Post by Gribouillis
1

After line 3, add

print(repr(password))
print(repr(userguess))

then you can compare visually the two strings.

0

thank you i tried it this just and it worked. what does repr() mean?

Edited by ankman

0

I could not explain this better than the python documentation. An advantage of printing the repr of a string is that you can see the non printable characters contained in the string. For example a newline character is represented as \n.

Edited by Gribouillis

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.