4 ms·
Because chaining the operator results in: > if x in odds == expect_odd : > if x in odds and odds == expect_odd : with the latter always evaluating to False
by wadkar 6y ago
Because chaining the operator results in:
> if x in odds == expect_odd :
> if x in odds and odds == expect_odd :
with the latter always evaluating to False (assuming expect_odd is a boolean flag).
- weare138 6y agoI'm not a Python expert so I don't know much about the internals of Python but my hunch is when Python evaluates 'x in odds' it's not storing that value internally as a boolean so when you use the '==' strict comparison Python is expecting both data types to be the same.