Others explained what was happening. Here are some ways to get what you want:
>>> a = [True, True, True] >>> b = [True, True, False]
Use listcomp:
>>> [ai and bi for ai,bi in zip(a,b)] [True, True, False]
Use the and_ function with map :
>>> from operator import and_ >>> map(and_, a, b) [True, True, False]
Or my preferred method (although this requires numpy ):
>>> from numpy import array >>> a = array([True, True, True]) >>> b = array([True, True, False]) >>> a & b array([ True, True, False], dtype=bool) >>> a | b array([ True, True, True], dtype=bool) >>> a ^ b array([False, False, True], dtype=bool)
source share