0

How to determine if a string is a substring of another? Give an example pls.

1st Oct 2018, 1:06 AM
partha
partha - avatar
2 Respuestas
+ 2
Is this what you are looking for? print("ham" in "champ") #True print("ham" in "spam") #False
1st Oct 2018, 1:32 AM
Kishalaya Saha
Kishalaya Saha - avatar
+ 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
1st Oct 2018, 2:20 AM
Flandre Scarlet
Flandre Scarlet - avatar