I'm trying to understand how the any() and all() Python built-in functions work. I'm trying to compare the tuples so that if any value is different then it will return True and if they are all the same it will return False. How are they working in this case to return [False, False, False]? d is a defaultdict(list). print d['Drd2'] # [[1, 5, 0], [1, 6, 0]] print list(zip(*d['Drd2'])) # [(1, 1), (5, 6), (0, 0)] print [any(x) and not all(x) for x in zip(*d['Drd2'])] # [False, False, False] To my knowledge, this should output # [False, True, False] since (1,1) are the same, (5,6) are different, and (0,0) are the same. Why is it evaluating to False for all tuples? See Pythonic way of checking if a condition holds for any element of a list for practical usage of any. Continue reading...