Formal letter increasing rate of violence?
Answers
Answered by
1
Answer:
The easiest way to check if a Python string contains a substring is to use the in operator. The in operator is used to check data structures for membership in Python. It returns a Boolean (either True or False) and can be used as follows:
fullstring = "StackAbuse"
substring = "tack"
if substring in fullstring:
print "Found!"
else:
print "Not found!"
This operator is shorthand for calling an object's __contains__ method, and also works well for checking if an item exists in a list.
Similar questions