Oct-23-2017, 02:10 AM
I now get the error:
#while guess[len(guess)-1] <= AlphaNum[len(AlphaNum)-1]: #IndexError: string index out of rangeIf I'm not mistaking, I looks like my program is trying to compare a one-char length guess string with a three-char length AlphaNum (such as 'a' with 'abc'). But that's not what what I'm trying to do. Currently, my guess string is only one char as I have declared it on line 9 of the code below, so guess[len(guess)-1] should just equal guess[0], and AlphaNum[len(AlphaNum)-1] should simply be referring to the last char in AlphaNum:
#!/usr/bin/env python3 #PasswordGuesser.py AlphaNum = "abc" guess = "" guessMatches = False password = "b" guessLength = len(guess) guessLength = 1 #start with a guess length of just one char def iterateAlphaNum(): i = 0 while i < len(AlphaNum): guess[0] == AlphaNum[i] i += 1 #Master While Loop: while the last char of the guess string has not yet passed #the last char in AlphaNum while guess[len(guess)-1] <= AlphaNum[len(AlphaNum)-1]: guess[0] = iterateAlphaNum() print(guess) if guess == password: guessMatches = True print() print("Found the password! It's " + str(guess)) breakAny ideas?