The
In real, you compare
You should also use a function instead and a context manager with a for-loop inside:
splitlines()
method and also the iteration over a file-object, does not strip the line ending.In real, you compare
123456\n
with password
and so on. Use the method rstrip()
to get rid of line endings and white space on the right side of the str
.You should also use a function instead and a context manager with a for-loop inside:
def test_password(): gefragt = input("Zu testendes Passwort: ") with open("passwoerter.txt") as fd: for password in fd: if password.rstrip() == gefragt: return True return FalseUsing the function:
if test_password(): print ("Sicher") else: print("Unsicher")
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
All humans together. We don't need politicians!