# Indexerror: tuple index out of range

1 vote
50 views

## Problem:

indexerror: tuple index out of range what does it mean? Why I am getting this error?
Please shed some light on this if possible.

Gratitude.

## Solution:

The “IndexError” happens when you run out of your array length. This error happens with the following code:

``````>>> test_tuple = (1, "Hello", True)
>>> len(test_tuple)
3
>>> test_tuple[0]
1
>>> test_tuple[3]  # Trying to access the 4th element
IndexError: tuple index out of range``````

Now coming to the second part of your question. Please focus on this simple python program. I got the error when I tried to access the element I don’t have ever. This is similar to trying to access the 10th element of a list of length 9.
I hope you get the point. Thanks.

## Related questions

42 views
I wrote a code in python : l = [8, 5, 4] total = l[0] + l[1] print (total) def count(a): total = 0 for i in a: total+= a[i] return total print (count(n)) but it has some error: File "main.py", line 11 return total ^ SyntaxError: 'return' outside function What is this error causing for?
37 views
Problem: Please consider the following code: i = [1, 2, 3, 5, 8, 13] j = [] k = 0 for l in i: j[k] = l k += 1 print j The output (Python 2.6.6 on Win 7 32-bit) is: > Traceback (most recent call last): > j[k] = l IndexError: list assignment index out of range I guess it's something simple I don't understand. Can someone clear it up?
1 vote
315 views
Problem: I have been doing programming for a while and I am using python for this. So my question is What is an advantage of using a tuple rather than a list? Thank you
3 views
Problem: I am getting an error stating that the pop index of g in indexList is out of range: IndexError: pop index out of range
4 views
Problem Looking for guidance to handle indexerror list index out of range in python.
1 vote
4 views
Problem: How to fix this error : python indexerror list index out of range
1 vote
2 views
Problem: Any ideas on what I need to do to fix this? python indexerror: list index out of range
1 vote