0
How to determine if a string is a substring of another? Give an example pls.
2 Answers
+ 2
Is this what you are looking for?
print("ham" in "champ") #True
print("ham" in "spam") #False
+ 2
Kishalaya's solution is already good, but still other methods
print("champ".find("ham")) # 1
print("spam".find("ham")) # -1
>>> give the index if found, else -1