This question already has an answer here:
这个问题在这里已有答案:
- IndexError: list index out of range and python 6 answers
- IndexError:列表索引超出范围和python 6答案
I am a beginner programmer and im not sure what this means...
我是初学程序员,我不知道这意味着什么......
Index Error: list index out of range
索引错误:列表索引超出范围
1 个解决方案
#1
29
Generally it means that you are providing an index for which a list element does not exist.
通常,这意味着您要提供不存在列表元素的索引。
E.g, if your list was [1, 3, 5, 7]
, and you asked for the element at index 10, you would be well out of bounds and receive an error, as only elements 0 through 3 exist.
例如,如果您的列表是[1,3,5,7],并且您要求索引10处的元素,那么您将完全超出界限并收到错误,因为只存在元素0到3。
#1
29
Generally it means that you are providing an index for which a list element does not exist.
通常,这意味着您要提供不存在列表元素的索引。
E.g, if your list was [1, 3, 5, 7]
, and you asked for the element at index 10, you would be well out of bounds and receive an error, as only elements 0 through 3 exist.
例如,如果您的列表是[1,3,5,7],并且您要求索引10处的元素,那么您将完全超出界限并收到错误,因为只存在元素0到3。