[Tutor] Why isn't my simple if elif script not working?
Ross Wilson
rzzzwilson at gmail.com
Wed Jul 18 07:54:20 CEST 2012
On 18/07/12 15:09, Santosh Kumar wrote:
> Here is my script:
>
> name = raw_input("What's your name? ")
>
> if name == "Santosh":
> print "Hey!! I have the same name."
> elif name == "John Cleese" or "Michael Palin":
> print "I have no preference about your name. Really!!"
> else:
> print "You have a nice name."
>
>
> The if part works well. The elif part works well too. The problem is
> even if you enter strings other than "Santosh", "John Cleese" and
> "Michael Palin" you still get the print from elif part, not from else
> part.
> _______________________________________________
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
Note that you *can* do:
if name in ("John Cleese", "Michael Palin"):
Ross
More information about the Tutor
mailing list