About 714,000 results
Open links in new tab
  1. How to check if a string contains an element from a list in Python

    The difference is, I wanted to check if a string is part of some list of strings whereas the other question is checking whether a string from a list of strings is a substring of another string. Similar, but not quite …

  2. python - How to check if a string is a substring of items in a list of ...

    It's a nice solution, but if you want to find the items which contain the given string, you will not succeed. Here you find out if any of the items contains the string.

  3. How to check if any item in a list contains a string in Python?

    Feb 24, 2022 · If you simply want to check if there are any exact matches of the substrings, then iterate over the items in item_list and use the in keyword, e.g., item in String_text. I suggest familiarizing …

  4. Filtering a list of strings based on contents - Stack Overflow

    Jan 28, 2010 · This simple filtering can be achieved in many ways with Python. The best approach is to use "list comprehensions" as follows:

  5. string - Finding a substring within a list in Python - Stack Overflow

    Dec 6, 2017 · 161 This question already has answers here: How to check if a string is a substring of items in a list of strings (17 answers)

  6. python - How do I check existence of a string in a list of strings ...

    return True else: print 'val is '+str(val) return False Without looping through the entire character string and/or using RegEx's (unless those are the most efficient), how should I go about this in a pythonic …

  7. Does Python have a string 'contains' substring method?

    Aug 9, 2010 · 571 Does Python have a string contains substring method? 99% of use cases will be covered using the keyword, in, which returns True or False:

  8. python - How to check if a list contains a string - Stack Overflow

    Oct 2, 2016 · I need to iterate through a list and check if the value is a string or an int. Is there any easy way to do this in python? For example: [1,2,3] would be true. ["a",2,3] would be false.

  9. Removing elements from a list containing specific characters

    I want to remove all elements in a list which contains (or does not contain) a set of specific characters, however I'm running in to problems iterating over the list and removing elements as I go along.

  10. Check if string contains any list element - Stack Overflow

    Jul 17, 2016 · Are you trying to find the positions of everything in that list, or are you trying to check if anything in that list is contained in your string?