Nov-19-2022, 11:02 PM
You don't understand how "or" works in Python.
You think the statement "if action == "/cash" or "/money":' is True if action is either "/cash" or "/money". But Python evaluates this statement in a very different way. Python thinks the value of the statement is True if action == "/cash", otherwise the value of the statement is "/money". This seen if you print the value of the or statement.
If a is truthy, return a
otherwise return b
For your particular or statement, the "a" part is
You think the statement "if action == "/cash" or "/money":' is True if action is either "/cash" or "/money". But Python evaluates this statement in a very different way. Python thinks the value of the statement is True if action == "/cash", otherwise the value of the statement is "/money". This seen if you print the value of the or statement.
action = "/cash" print(action == "/cash" or "/money") action = "/money" print(action == "/cash" or "/money") action = "something else" print(action == "/cash" or "/money")
Output:True
/money
/money
The reason for this is that Python evaluates "a or b" in this way:If a is truthy, return a
otherwise return b
For your particular or statement, the "a" part is
action == "/cash"
and the "b" part is "/money"
. action == "/cash"
will be either True or False. If it is True, the value of the or statement is True (the value of "a"). If it is not True, the value of the if statement is "/money" (the value of "b").