views:

531

answers:

5

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?

+2  A: 

yes. sequence doesn't have the 54th item.

SilentGhost
Try printing 42 instead. It should be the correct answer.
wuub
+2  A: 

If you have a list with 53 items, the last one is thelist[52] because indexing start at 0.

Alex Martelli
+1  A: 

It seems so, yes.

H_I
+1  A: 

That's right. 'list index out of range' most likely means you are referring to n-th element of the list, while the length of the list is smaller than n.

Grzegorz Oledzki
+4  A: 

Yes,

You are trying to access an element of the list that does not exist.

MyList = ["item1", "item2"]
print MyList[0] # Will work
print MyList[1] # Will Work
print MyList[2] # Will crash.

Have you got an off-by-one error?

kjfletch