How to Check if Python String Contains a Substring?
To check if a Python string contains a given substring, use the in operator:
if "bcd" in "abcde":
print("YES")
To get the index of the substring if present, use the find function:
idx = "abcde".find("cd")
print(idx)
# the above will print 2 in this case
# it will print -1 if the substring is not found