How can I check if any of the strings in an array exists in another string?
Like:
a = ['a', 'b', 'c']
str = "a123"
if a in str:
print "some of the strings found in str"
else:
print "no strings found in str"
That code doesn't work, it's just to show what I want to achieve.
Just some more info on how to get all list elements availlable in String
You need to iterate on the elements of a.
It depends on the context suppose if you want to check single literal like(any single word a,e,w,..etc) in is enough
if you want to check any of the character among the original_word: make use of
if you want all the input you want in that original_word,make use of all simple
You can use
any
:Similarly to check if all the strings from the list are found, use
all
instead ofany
.