Python Bandingkan dua daftar
>>> a = [1, 2, 3, 4, 5]
>>> b = [9, 8, 7, 6, 5]
>>> set(a) & set(b)
{5}
Stupid Shrike
>>> a = [1, 2, 3, 4, 5]
>>> b = [9, 8, 7, 6, 5]
>>> set(a) & set(b)
{5}
[ x&y for (x,y) in zip(list_a, list_b)]
>>> [i for i, j in zip(a, b) if i == j]
[5]
a = [1, 2, 3, 4, 5]
b = [9, 8, 7, 6, 5]
returnMatches(a, b)
#would return [5], for instance