how to compare elements in same list python code example
Example 1: how to compare two lists element by element in python and return matched element
>>> [i for i, j in zip(a, b) if i == j]
[5]
Example 2: python compare each item of one list
import itertools
for a, b in itertools.combinations(mylist, 2):
compare(a, b)