On Fri, Mar 16, 2012 at 3:02 PM, Alan Gauld <alan.ga...@btinternet.com> wrote: > 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/ > > Good Catch! I originally had the pass in alone, but then decided to give a helpful message. Didn't remove the pass > _______________________________________________ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > http://mail.python.org/mailman/listinfo/tutor
-- Joel Goldstick _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor