IndexError:list assignment index out-range Python 3这意味着什么?如何修复它?
这是刽子手代码的一部分。 它说错误在以下范围内:IndexError:list assignment index out-range Python 3这意味着什么?如何修复它?,python,python-3.x,syntax-error,Python,Python 3.x,Syntax Error,这是刽子手代码的一部分。 它说错误在以下范围内: 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 d
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
这意味着
计数
大于破折号的长度
。因为我们不知道破折号应该包含什么,所以很难说得更多。破折号的长度只能是0或不可编辑。打印破折号并不能直接在导致eror的行之前。破折号应该包含单词每个字符的破折号,所以如果单词是“hiya”,那么破折号就是“----”。谢谢
dash[count - 1] = letterGuess