I have 2 lists: a = ['5', '2', '3', '4']
, and b = ['1', '6', '7', '5']
. Using Python 2, how can I compare each list element in a
to each element in b
? (i.e. is a[0] == b[0]
, is a[0] == b[1]
, etc).
I know that I could just write out numerous if
statements, but I hope that there is a more elegant way to do this.
After checking each list element, I want to know how many times a shared value was found (in my example lists above, it would be one time, '5'
).
EDIT: This is not a duplicate, b/c i am comparing two different lists to each other, while the possible duplicate dealt with only 1 list.