I want to take two lists and find the values that appear in both.
A = ['A7', 'B4', 'B7']
B = ['A7', 'B7', 'C7', 'D7', 'E7', 'F7', 'G7', 'H7', 'I7']
returnMatches()
would return ['A7', 'B7']
.
I want to take two lists and find the values that appear in both.
A = ['A7', 'B4', 'B7']
B = ['A7', 'B7', 'C7', 'D7', 'E7', 'F7', 'G7', 'H7', 'I7']
returnMatches()
would return ['A7', 'B7']
.
You can do this:
set(A) & set(B)
You can even construct them as sets from the beginning:
A = {'A7', 'B4', 'B7'}