I'd like to take two strings and check if the first string is a partial string of the second string.
ex) First sentence: Bad person
The second sentence: I am a bad person.
I'm a bad person.
First sentence: Ronaldo
Second sentence: messironaldoneymar
ronaldo is a substring of messironaldoneymar
s1 = 'ronaldo'
s2 = 'mess ronaldo'
if s1 in s2:
print(s1, 'is a substring of', s2)
Add.
Do you include the def string (key, text):
return key in text
s1 = 'ronaldo'
s2 = 'mess ronaldo'
Include if string (s1, s2):
print ('%s is a substring '%s' of %s)
Please delete the duplicate questions.
© 2025 OneMinuteCode. All rights reserved.