or.. def is_yes(question): while True: try: s = raw_input(question).lower()[0] if s == 'y': return True elif s == 'n': return False except: pass ## This traps the condition where a user just presses enter print '\nplease select y, n, yes, or no\n'
-----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of scott Sent: Wednesday, June 06, 2007 3:08 PM To: tutor@python.org Subject: Re: [Tutor] Engarde program was: i++ Alan Gauld wrote: > You never change i so this is always true. > Therefore you can express that better with... Thanks for your suggestions, I put together the following based on them: ############################################## def is_yes(question): while True: s = raw_input(question).lower() if s == 'y' or s == 'yes': return True elif s == 'n' or s == 'no': return False else: print '\nplease select y, n, yes, or no\n' ################################################ It seems to work perfectly :) -- Your friend, Scott Sent to you from a Linux computer using Kubuntu Version 7.04 (Feisty Fawn) _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor