John Salerno wrote:
> Here's an exercise I was doing to guess a number from 1-100. 

Here's another question that is related:

while True:
     year = raw_input('Enter year (or other character to quit): ')

     try:
        year = int(year)
     except NameError:
        break

     if (year % 4 == 0) and (year % 100 != 0 or year % 400 == 0):
        print year, 'is a leap year.\n'
     else:
        print year, 'is not a leap year.\n'

raw_input()

This works as expected, except that if you enter any character other 
than a number, the program just quits. Why doesn't it still execute the 
raw_input function and pause? I think this is what is happening in the 
other exercise too, but I don't know why. If you break out of the loop, 
should it still pause at raw_input?
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to