if-else-then
Francesco Bochicchio
bockman at virgilio.it
Sat Sep 11 08:55:06 EDT 2004
On Sat, 11 Sep 2004 05:34:42 -0700, TuPLaD wrote:
> Thank you very much !
>
> But i got one more question, i was googling in python sites, and i
> found a site where he he a code like this :
>
>
> if user type: n, no, nop, nope then print 'You canceled'
> else
> if user type: y, ye, yes, yep then print 'We are beginning'
>
>
> How do i do that ?
>
Not much differently from what you have already written :-)
user_string= raw_input("Tell me:")
if user_string in 'y', 'ye', 'yes', 'yep':
print "We are beginning"
elif user_string in 'n', 'no', 'nop', 'nope':
print "You canceled"
More information about the Python-list
mailing list