fullstring = "StackAbuse"
substring = "tack"
if fullstring.find(substring) != -1:
print "Found!"
else:
print "Not found!"
>>> string = "Hello World"
>>> # Check Sub-String in String
>>> "World" in string
True
>>> # Check Sub-String not in String
>>> "World" not in string
False
>>> str = "Messi is the best soccer player"
>>> "soccer" in str
True
>>> "football" in str
False
fullstring = "StackAbuse"
substring = "tack"
if substring in fullstring:
print("Found!")
else:
print("Not found!")
from re import search
fullstring = "StackAbuse"
substring = "tack"
if search(substring, fullstring):
print "Found!"
else:
print "Not found!"
mystring = ["reddit", "google"]
mylist = ["a", "b", "c", "d"]
print [s for s in mystring if not any(x in s for x in mylist)]
str = '£35,000 per year'
# check for '£' character in the string
'£' not in str
# >> False
'£' in str
# >> True