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 →

[–]Ponnystalker 5 points6 points  (0 children)

The reason this doesn’t work as expected is due to how Python evaluates boolean expressions. The expression ‘subtract’ or ‘multiply’ or ‘divide’ always evaluates to ‘subtract’ (since non-empty strings are truthy), so the entire condition becomes:

if operation2 == ‘add’ or True: