I'm trying to make a password cracker for a project at school, but I've run into a problem. Here's the code:
dictfile = open('c:/ScienceFairDictionaryFolder/wordsEn.txt', 'r')
DictionaryWords = dictfile.readlines()
Password = "abductors"
for x in DictionaryWords:
if x is Password:
print("Found it!")
else:
print("This password can't be guessed!")
So everytime I run this code, I only get:
"This password can't be guessed!"
However, I made sure the word was in the dictionary I'm using, so I don't understand why the password isn't being guessed. Is there something I'm doing wrong with the code I'm using?
isfor string comparisons. Use==. 2: You have to remove the line ends:if x.strip('\r\n') == Password:.