[Tutor] I'm puzzled

Hugo González Monteverde hugonz-lists at h-lab.net
Mon Jan 23 01:11:09 CET 2006


Hi Vincent,

> the program works with any input except when you just hit the enter key.


To be  able to understand why is the crash, take a look at what the 
interpreter tells you:

 >  File "untitled.py", line 12, in ?
 >    elif a[0] == '-' and a[1:].isdigit():
 > IndexError: string index out of range

IndexError is raised whan you try to access an element in a list or 
string, an element that does not exist. In the case where you only press 
enter, what is the content of a???? How many characters? (hint, you may 
try to

print a

before any evaluation...

Hope that gets you going,

Hugo


More information about the Tutor mailing list