0

In an attempt to make my if statements cleaner, I figured out a simply way of making them quite a lot shorter. Instead of doing this:

elif talk_in == "quit" or talk_in == "q" or talk_in == "exit" or talk_in == "x":

I can do this:

elif talk_in == ("quit" or "q" or "exit" or "x"):

However, it will only return true if the first item within the parentheses makes it true. For example:

>>> talkin = "quit"
>>> talkin == ("quit" or "q")
True
>>> talkin == ("q" or "quit")
False

Why does this happen? And how can I fix it?

3
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by Gribouillis
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.