How do I check if a given Python string is a substring of another one?
Become part of the top 3% of the developers by applying to Toptal https://topt.al/25cXVn
--
Music by Eric Matyas
https://www.soundimage.org
Track title: Switch On Looping
--
Chapters
00:00 Question
00:22 Accepted answer (Score 510)
00:35 Answer 2 (Score 55)
00:46 Answer 3 (Score 42)
01:03 Thank you
--
Full question
https://stackoverflow.com/questions/5143...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #string #substring
#avk47
--
Music by Eric Matyas
https://www.soundimage.org
Track title: Switch On Looping
--
Chapters
00:00 Question
00:22 Accepted answer (Score 510)
00:35 Answer 2 (Score 55)
00:46 Answer 3 (Score 42)
01:03 Thank you
--
Full question
https://stackoverflow.com/questions/5143...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #string #substring
#avk47
ACCEPTED ANSWER
Score 516
Try using in like this:
>>> x = 'hello'
>>> y = 'll'
>>> y in x
True
ANSWER 2
Score 56
Try
isSubstring = first in theOther
ANSWER 3
Score 43
string.find("substring") will help you. This function returns -1 when there is no substring.