The
Probably the most natural way to do what you want is to turn the lists into sets and use one of the set operations (see, e.g. docs).
all
function doesn't work like that - it returns True
if all the values are truthy, which for integers means non-zero. So, your call to all
returns True
and the value True
is not in list_a
, so execution enters the else
branch.Probably the most natural way to do what you want is to turn the lists into sets and use one of the set operations (see, e.g. docs).