0

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'].

martineau
  • 119,623
  • 25
  • 170
  • 301
KDB
  • 173
  • 1
  • 4
  • 12

1 Answers1

0

You can do this:

set(A) & set(B)

You can even construct them as sets from the beginning:

A = {'A7', 'B4', 'B7'}
John Zwinck
  • 239,568
  • 38
  • 324
  • 436