Just starting to learn Python, and encounter a problem

Gordon Levi gordon at address.invalid
Fri Jul 22 10:37:33 EDT 2016


Zagyen Leo <zagyen at gmail.com> wrote:

>yeah, it may be quite simple to you experts, but hard to me.
>
>In one of exercises from the Tutorial it said: "Write a program that asks the user their name, if they enter your name say "That is a nice name", if they enter "John Cleese" or "Michael Palin", tell them how you feel about them ;), otherwise tell them "You have a nice name."
>
>And i write so:
>
>name = input("Enter your name here: ")
>if name == "John Cleese" or "Michael Palin":
>    print("Sounds like a gentleman.")
>else:
>    print("You have a nice name.")
>
>But strangely whatever I type in (e.g. Santa Claus), it always say "Sounds like a gentleman.", not the result I want.

The second line should be 
if name == "John Cleese" or name == "Michael Palin":

As discussed in recent lengthy thread in this group the following
line, and hence your statement, is always true -

If "Michael Palin":



More information about the Python-list mailing list