There are two common ways to check if a string contains a substring in Python:
in
keyword:main.py120 chars4 lines
find()
function:main.py129 chars4 lines
Both of these methods return True
if the substring is found in the string and False
otherwise. The find()
function returns the index of the first occurrence of the substring, or -1
if the substring is not found.
gistlibby LogSnag