IndexError: list index out of range and python

后端 未结 8 2257
醉酒成梦
醉酒成梦 2020-11-22 04:58

I\'m telling my program to print out line 53 of an output. Is this error telling me that there aren\'t that many lines and therefore can not print it out?

相关标签:
8条回答
  • 2020-11-22 05:11

    Always keep in mind when you want to overcome this error, the default value of indexing and range starts from 0, so if total items is 100 then l[99] and range(99) will give you access up to the last element.

    whenever you get this type of error please cross check with items that comes between/middle in range, and insure that their index is not last if you get output then you have made perfect error that mentioned above.

    0 讨论(0)
  • 2020-11-22 05:21

    In Python, indexing starts at 0. Therefore, if you have a list with 53 items, list[52] will be the last item in the list.

    0 讨论(0)
提交回复
热议问题