5 ms·
If I understand what you're getting at changing '==' to 'and' will make it work the way you're expecting. Both have to evaluate to 'True' in the if statement an
by weare138 7y ago
If I understand what you're getting at changing '==' to 'and' will make it work the way you're expecting. Both have to evaluate to 'True' in the if statement and passing 'False' to expect_odd will always print 'error'.
- bacon_waffle 7y agoThat wouldn't work for the even parity case. "(x in odds) == expect_odd" gives the intended behaviour and I think is easier to read as well.
- bnegreve 7y agoI know how to make this work, but a bug like this would be hard to spot.