Painting Blue Code
Simple, self-explanatory code snippets.
2018-05-15
PYTHON - Determine if ANY of the words in a list are found in a given string
wordsList = [ "
two
", "
long
" ]
string = "
this is a not very
long
phrase,
two
would be too many
"
if
any
(
word
in string for
word
in wordsList ):
print "yes, all given words are found in the given string"
else:
print "no, not all given words exist in the given string"
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment