>>> [i for i, j in zip(a, b) if i == j] [5]
import itertools for a, b in itertools.combinations(mylist, 2): compare(a, b)