python string contains any of list code example

Example 1: python check if list contains elements of another list

## checking all elements of list_B in list_A
list_A = [1, 2, 3, 4]
list_B = [2, 3]

check = all(item in list_A for item in list_B)

print(check)
# True

Example 2: check if anything in a list is in a string python

y = any(x in String for x in List)

Example 3: check if word contains a word in a list python

if any(word in 'some one long two phrase three' for word in list_):

Example 4: python check if list contains

# To check if a certain element is contained in a list use 'in'
bikes = ['trek', 'redline', 'giant']
'trek' in bikes
# Output:
# True

Example 5: if list item in string python

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

Tags:

Vb Example