1fullstring = "StackAbuse"
2substring = "tack"
3
4if fullstring.find(substring) != -1:
5 print "Found!"
6else:
7 print "Not found!"
8
1myString = "<text contains this>"
2myOtherString = "AnotherString"
3
4# Casting to string is not needed but it's good practice
5# to check for errors
6
7if str(myString) in str(myOtherString):
8 # Do Something
9else:
10 # myOtherString didn't contain myString
11
1>>> string = "Hello World"
2>>> # Check Sub-String in String
3>>> "World" in string
4True
5>>> # Check Sub-String not in String
6>>> "World" not in string
7False