[Tutor] Engarde program was: i++
David Heiser
David.Heiser at intelliden.com
Thu Jun 7 00:11:07 CEST 2007
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: tutor-bounces at python.org [mailto:tutor-bounces at python.org] On
Behalf Of scott
Sent: Wednesday, June 06, 2007 3:08 PM
To: tutor at 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 at python.org
http://mail.python.org/mailman/listinfo/tutor
More information about the Tutor
mailing list