Forums

Python string find() examples

https://python-reference.readthedocs.io/en/latest/docs/str/find.htmlhttps://python-reference.readthedocs.io/en/latest/docs/str/find.html

See also index() which throws a ValueError if not found rather than returning -1.

If you just want to know if something is a substring and are not so worried about its position see the in operator and startswith() and endswith() methods of string.

That link should have just been https://python-reference.readthedocs.io/en/latest/docs/str/find.html