On 16/03/12 14:44, Joel Goldstick wrote:
Take a look at this:
while True:
num = raw_input("give me an integer: ")
try:
n = int(num)
break
except:
print "Sorry, that wasn't and integer!"
pass
The pass is redundant it does nothing (thats its purpose! :-)
You can also remove the variable n:
while True:
try:
num = int(raw_input("give me an integer: "))
# use num now or keep it for later
break
except:
print "Sorry, that wasn't an integer!"
# can also use num here...
HTH
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor