Take the 2-minute tour ×

Python 2.7.5 and OSX 10.8 here

I'm trying to plot some datas I get from a file. I'm trying to code a function where the user is able to plot from the point he wants, and have come to this part of code :

firstPoint = raw_input("1st point to be displayed is n° : ")

tbdata3 = hdulist[3].data
print tbdata3.field('DDL_FT_OPL')
print tbdata3.field('DDL_SC_OPL')


I get this error :

Traceback (most recent call last):
File "/Users/geoffroysarrazin/Desktop/stage_observatoire/testEkki.py", line 52, in essai
IndexError: invalid slice

And it seems weird to me, cause I got this with


and just before, I had a constant value instead of this input from the user, which was equal to 200 (or whatever <400) and it worked...

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

Simple - you're not converting your input!

firstPoint = int(raw_input("1st point to be displayed is n° : "))

You can add some exception handling to re-prompt the user if he doesn't provide a number, if you so wish.

share|improve this answer
Yeah thank's, I forgot to cast -____-" Sorry for that question I feel even dumber than before ahah –  Geo Jul 9 '13 at 15:30
It happens...frustratingly often. And, to be fair, invalid slice isn't a very useful error message. –  Bhajun Singh Jul 9 '13 at 18:09
add comment

Your Answer


