TypeError: list indices must be integers

T

Terry Reedy

I got this error twice today
while creating lists of lists
of complicated stuff.
The first time I was puzzled,
but the second time I knew
that I had just forgotten a comma.
If you google this, you will too.

Reduced example
[4,5,6]]
Traceback (most recent call last):
File "<pyshell#10>", line 2, in <module>
[4,5,6]]
TypeError: list indices must be integers, not tuple

Terry Jan Reedy
 
J

Jon Clements

I got this error twice today
while creating lists of lists
of complicated stuff.
The first time I was puzzled,
but the second time I knew
that I had just forgotten a comma.
If you google this, you will too.

Reduced example
 >>> [[1,2,3] # forgot comma
      [4,5,6]]
Traceback (most recent call last):
   File "<pyshell#10>", line 2, in <module>
     [4,5,6]]
TypeError: list indices must be integers, not tuple

Terry Jan Reedy

Umm... +1 for poetic effort?

Jon.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,125
Latest member
VinayKumar Nevatia_
Top