The problem is here: i in even or odd
This is parsed as such:
(i in even) or (odd)
.
Python unhelpfully tries to convert the odd
list into a boolean value (in this case True
because the list is not empty).
Try i in even or i in odd
, which correctly checks if i
is present in either even
or odd
.