str_list = ["one", "two", "three"] substr = "wo" if any(substr in str for str in str_list): print('Yes!')
Here is what the above code is Doing:
1. We have a list of strings, str_list.
2. We have a string, substr.
3. We use the any() function to check if any of the strings in str_list contain substr.
4. If any of the strings in str_list contain substr, we print ‘Yes!’.