I want to compare a value to a list and if all of the values are True, return True. If any values are False, return False. For example:
all(3 < [3,4,5])
Should return False.
all(3 < [4,5])
Should return True. However, I get this error:
TypeError: '<' not supported between instances of 'int' and 'list'
This runs:
3 < all([4,5])
but doesn't produce the right answer because 3 is greater than [True, True]. I apologize if this is a duplicate, but of the 6 examples I found of this error on SO, none of them answer my question. The weird thing is I feel like I have successfully used this in the past without issues. I am running Python 3.7.3 on a Macbook.
all(3 < i for i in [4, 5])
all
acts on a sequence of Booleans; it does not distribute over arbitrary arguments. A search for a tutorial is usually a good idea before posting.