I have two questions on these simple programs:

1st why does this loop keep repeating after I enter 'Quit'?

import calendar
m = raw_input(“Enter a year: “)
while m != “Quit”:
 if calendar.isleap(int(m)):
  print “%d is a leap year” % (int(m))
 else:
  print “%d is not a leap year” % (int(m)) 


2nd  How can I make this program not crash when a user enters a non integer?

m = raw_input(“Enter an integer: “)
while not m.isdigit():
 m = raw_input(“Enter an integer: “)
 num = int(m)
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to