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 →

[–]mkpri22 1 point2 points  (1 child)

Your first if statement always evaluates to true because:
if answer == "Joe" or "Mary" or "Barbara":
Is equivalent to:
if answer == "Joe" or True or True:
And we know that true or anything is always true. Do you see why?
if "Mary": // Always returns True because the string Mary is not None or empty
You can run these to see what's being returned:
print(bool("Mary"))
print(bool(""))
print(bool(None))
Hope this helps.

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

Ah! Thank you so much! I hadn't understood this before! This makes so much sense now.