Saturday, November 14, 2015

String contains in python

s = "A nice string search 234"
res = ""
items = ['a', '4', '6']
for x in items:
#print x
if s.find(x) == -1:
res = x + " is not in given string"
print  res
else:
res = x + " is in given string"
print res

No comments:

Post a Comment