1455. Check If a Word Occurs As a Prefix of Any Word in a Sentence
On This Page
class Solution:
def isPrefixOfWord(self, sentence: str, searchWord: str) -> int:
for i, s in enumerate(sentence.split(), 1):
if s.startswith(searchWord):
return i
return -1