Trying to develop a text based Hangman game in Python and want to use multi arrays to hold the words to guess but separated into individual letters.
I'm currently getting this error: TypeError: list indices must be integers or slices, not tuple
.
Any ideas?
words = [['d', 'u', 'c', 'k'],
[],
[],
[],
[]]
My thought would be that if I ask to print array 1, 1 then I would get back "d"
?
if i ask to print array 1, 1 then i would get back "d"?
No that would return an error, as arrays start at 0.
So you must return words[0][0], that would get you back "d".
将您的列表索引为words[j][i]
而不是words[i, j]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.