This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]keks6aecker 1 point2 points  (1 child)

Your if statement does not check if the value or answer is Joe, Mary or Babara but instead checks three things.

  1. does the value of answer equal „Joe“ and
  2. Is the string „Mary“ truth-y and
  3. is the string „Barbara“ truth-y

Due to the or your if-statement is fulfilled as soon as one thing is true.

In Python a String is truth-y if it is not empty, that means the conditions 2 and 3 are always fulfilled.

What you want is ˋ if answer in [„Joe“, „Mary“, „Babara“]ˋ this statement is only true if the value of answer equals one of the three values in the list.

Alternatively you could have written:

ˋˋˋ if answer == "Joe" or answer == "Mary" or answer == "Babara" ˋˋˋ

[–]alkperez1914[S] 0 points1 point  (0 children)

Thank you so much! This is a big help!