0
elif letterGuess in letterList: # if the letter is one the word characters
count = 1
print (letterGuess, ' is in the word!')
for n in letterList:
if n == letterGuess: # replaces the dashes with letters
dash[count - 1] = letterGuess # takes the dash in position and replaces
count += 1
count = 0
這是hangman的一些代碼的一部分。 它說誤差行內:IndexError:列表分配索引超出範圍Python 3這是什麼意思,我該如何解決它?
dash[count - 1] = letterGuess
短劃線應該包含單詞的每個字符的短劃線,所以如果單詞是'hiya',那麼短劃線是'----'。謝謝! – zara