-2
list = ["1", "2", "3"]
string=  abc1def

How can I check if ANY items of my list is contained within my string?

user3011784
  • 833
  • 1
  • 8
  • 30
  • You can just check each member in a loop, but may find a more efficient mechanism from creating a generator and calling `next()` to only get the first match if you have a great many members – ti7 Feb 22 '22 at 18:58

1 Answers1

0
any(substr in string for substr in list_)
Marat
  • 15,215
  • 2
  • 39
  • 48