Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python string starts with any char of list

# `str.startswith` supports checking for multiple prefixes:
>>> "abcde".startswith(("xyz", "abc"))
True
# You must use a tuple though, so convert your lists using tuple()
>>> prefixes = ["xyz", "abc"]
>>> "abcde".startswith(tuple(prefixes))
True
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #python #string #starts #char #list
ADD COMMENT
Topic
Name
5+5 =