list index out of range, reading data and saving a variable

Asked

Viewed 54 times

0

Hello! I need to read a data that is in a list at position 13 and is repeated every 15 values. Using the following code I receive error message:

for i in range(0,len(dado),15):
         lat = texto.pop(13+i)

The error message is: Indexerror: list index out of range. The array has 15 thousand values, I do not understand why this error :/

  • 2

    Imagine that dado has 35 records. Your for will set the sequence 0, 15 and 30, which will cause you to access positions 13 (13+0), 28 (13+15) and 43 (13+30). Heading 43 does not exist in your list.

  • humm, interesting. I’m still learning python. I appreciate the help!

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.