I'm guessing when you did that, you got something like an IndexError. That's because you didn't check the length of "a" from raw_input and accessed a nonexistent array element (a string is an array of characters). So if you changed the line: elif a[0] == '-' and a[1:].isdigit(): to : elif len(a) > 1 and a[0] == '-' and a[1:].isdigit():
I expect you'll get what you want. --Shuying On 1/23/06, Vincent Zee <[EMAIL PROTECTED]> wrote: > Hi all, > > I'm puzzled (:-)) > > Why will this little program crash when you enter the > enter key? > > while True: > a = raw_input('number? ') > if a.isdigit(): > print 'isdigit' > elif a[0] == '-' and a[1:].isdigit(): > print '- + isdigit' > elif a == 'q': > break > else: > print 'no digit' _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor