-2
cN = 0
lN = 0
while currentCharNo < wordListLength[lN]:
WordfromList = wordList[lN]
CharList = []
wordChar = WordfromList[cN]
CharList.append(wordChar)
charOfWordsList = []
cN = cN + 1
currentCharNo = currentCharNo + 1
我得到錯誤行wordChar = WordfromList[cN]
。我真的不理解它,因爲它對我來說似乎是完全正確的語法。Python「IndexError:字符串索引超出範圍」
謝謝!
與語法無關。這只是因爲'len(WordfromList)> = cN' –
@ Jean-FrançoisFabre你是指'<='? –
我不明白這一點。假設'WordfromList =「apple」'。那麼,因爲'cN = 0',不應該'WordfromList [cN']只是返回'a'? – AKMan6