0

For example I want the out put here to be true because 1 is in the second list

[1,2,3] in ['a', 'b', 'c', 1]

I want like if any object from the first list is in the second list then return true

ADHAM Al-Moqdad
  • 41
  • 1
  • 1
  • 4

1 Answers1

2

You can use any (which outputs True if any element in a list is True) with a generator expression:

any(i in ['a', 'b', 'c', 1] for i in [1,2,3])
sacuL
  • 49,704
  • 8
  • 81
  • 106