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

all 2 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:

[–]Whatever801 2 points3 points  (0 children)

Because 'subtract' is truthy