Python's any() function on a list of lists gives weird outputs
Your syntax is wrong. You are first computing any(a)
(which is True
) then check if True
is in your target list. The reason it sometimes returns True
is the fact that int(True)
is equal to 1
, so it only prints True
if your target list contains a 1
.
Try this, for example:
print(any(x in [4,5,7,6] for x in a)) # Should print True