IndexError: tuple index out of range ----- Python
Solution 1:
Probably one of the indices is wrong, either the inner one or the outer one.
I suspect you meant to say [0]
where you said [1]
, and [1]
where you said [2]
. Indices are 0-based in Python.
Solution 2:
A tuple consists of a number of values separated by commas. like
>>> t = 12345, 54321, 'hello!'
>>> t[0]
12345
tuple are index based (and also immutable) in Python.
Here in this case x = rows[1][1] + " " + rows[1][2]
have only two index 0, 1 available but you are trying to access the 3rd index.