How to check if a string is a substring of items in a list of strings
You can use a for loop to iterate through the list of strings, and then use the in keyword to check if the string is a substring of the current item in the list.
You can use a for loop to iterate through the list of strings, and then use the in keyword to check if the string is a substring of the current item in the list. Here is an example:
Using a for loop to check if a string is a substring of items in a list of strings in Python
Watch a video course: Python - The Practical Guide
Alternatively you can use any() with a generator expression which is more pythonic and better performant
Using a generator expression to check if a string is a substring of items in a list of strings in Python
This will return True if the string is a substring of any of the items in the list, and False otherwise.