Does Python have a string ‘contains’ substring method?
Posted By: Anonymous
I’m looking for a string.contains
or string.indexof
method in Python.
I want to do:
if not somestring.contains("blah"):
continue
Solution
You can use the in
operator:
if "blah" not in somestring:
continue
Answered By: Anonymous
Disclaimer: This content is shared under creative common license cc-by-sa 3.0. It is generated from StackExchange Website Network.