How to do a string contains in Python

To use String.Contains in Python you can use the IN operator.

testString = "Hello World 2015"
if "World" not in testString:
print("World is not in String")
else:
print("World is in String")

Please Share us:
Please rate this snippet

2 thoughts on “How to do a string contains in Python

Leave a Reply