xxxxxxxxxx
if 'apples' in 'This string has apples':
print('Apples in string')
else:
print('Apples not in string')
xxxxxxxxxx
fullstring = "StackAbuse"
substring = "tack"
if fullstring.find(substring) != -1:
print "Found!"
else:
print "Not found!"
xxxxxxxxxx
fullstring = "StackAbuse"
substring = "tack"
if substring in fullstring:
print "Found!"
else:
print "Not found!"
xxxxxxxxxx
>>> str = "Messi is the best soccer player"
>>> "soccer" in str
True
>>> "football" in str
False
xxxxxxxxxx
fullstring = "StackAbuse"
substring = "tack"
if substring in fullstring:
print("Found!")
else:
print("Not found!")
xxxxxxxxxx
from re import search
fullstring = "StackAbuse"
substring = "tack"
if search(substring, fullstring):
print "Found!"
else:
print "Not found!"
xxxxxxxxxx
mystring = ["reddit", "google"]
mylist = ["a", "b", "c", "d"]
print [s for s in mystring if not any(x in s for x in mylist)]