`In printing out a list item by item.What does the error "list index out of range" means?
Let us assume that this is our list:
x = ["a", "b", "c"]
Elements of list
"c". Corresponding indices are:
So, for example, to access element
"b" we can use
Error list index out of range indicates that you have tried to access an element at the index that does not exist.
For our exemplary list
x it might be index
>> print x IndexError: list index out of range
Because as we stated before, valid indices for our list are
To spot the problem check all the places where you are getting value of the element of the list by index.
Thank you! I used len(n) instead of len(x).now its correct:relaxed:
Great! You're very welcome
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.