I'm using python 2 and I want to compare between item in a list but I got stucked. Here's the problem:
x = [True, False, True, True, False]
how do i get the result to process the boolean (True & False & True & True & False)?
thanks before
If I understand your question correctly, you want the all function.
x = [True, False, True, True, False]
all(x)
The all function goes from left to right within an iterable, and evaluates each term in a boolean context. If it reaches any False (or False-ish, like None) value, it returns False immediately, just as if you'd written a and b and c and d out by hand. If it encounters only truthy values, it returns True.
Related: there's a similar function, called any, that does the same thing using or instead of and. So in your case, all(x) returns False, but any(x) would return True, since there's at least one truthy value.
Series objects even have their own all methods already.