check string in a list python code example

Example 1: if string is in array python

if item in my_list:
    # whatever

Example 2: if list item in string python

if any(ext in url_string for ext in extensionsToCheck):
    print(url_string)

Example 3: python how to check in a list

# app.py

listA = ['Stranger Things', 'S Education', 'Game of Thrones']

if 'Dark' in listA:
    print("Yes, 'S Eductation' found in List : ", listA)
else:
    print("Nope, 'Dark' not found in the list")

Example 4: check if list contains string python

some_list = ['abc-123', 'def-456', 'ghi-789', 'abc-456']
if any("abc" in s for s in some_list):
    # whatever