Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python if any element in string

# Basic syntax:
any(elem in your_string for elem in elements)
# Where:
#	- elements is an iterable
#	- any() will return true if any of the elements in elements is in
#		your_string, otherwise it returns False

# Example usage:
your_string = 'a short example string'
any(elem in your_string for elem in ['Malarkey', 23, 'amp'])
--> True # any() returns True because amp is in your_string
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #python #element #string
ADD COMMENT
Topic
Name
9+4 =