Hello all,
I just start to learn python, working on the chapter of THE BAGELS DEDUCTION GAME.
No matter how hard I am, the order just failed.
Always showing:
Line 20:
Thanks a lot..
Best
I just start to learn python, working on the chapter of THE BAGELS DEDUCTION GAME.
No matter how hard I am, the order just failed.
Always showing:
Error:Traceback (most recent call last):
File "/Users/qiyin/Downloads/Python37/bagels.py", line 56, in <module>
print(getClues(guess, secretNum))
File "/Users/qiyin/Downloads/Python37/bagels.py", line 20, in getClues
if len(guess[i]) == len(secretNum[i]):
IndexError: string index out of range
This is the order of Line 20 and line 56Line 20:
clues = [] for i in range(len(guess)): if guess[i] == secretNum[i]: clues.append('Fermi') elif guess[i] in secretNum: clues.append('Pico')Line56
while True: secretNum = getSecretNum() print('I have thought up a number. You have %s guesses to get it.' % (MAX_GUESS)) guessesTaken = 1 while guessesTaken <= MAX_GUESS: guess = '' while len(guess) != NUM_DIGITS or not isOnlyDigits(guess): print('Guess #%s: ' % (guessesTaken)) guess = input() print(getClues(guess, secretNum)) guessesTaken += 1Anyone could tell me what was happed?
Thanks a lot..
Best