I'm trying find word in the sentence, what i should do in order to find string in the sentence instead of each character of the string in sentence?
Note: i'm trying to achieve this using for loop. I don't want to use split() or in-build functions.
def word_in_sen(sentence, word):
result = ''
for i in word:
for j in sentence:
if i == j:
result += i
break
if result == word:
return True
else:
return False
print(word_in_sen("Welcome to python programming ", "python")) print(word_in_sen("Welcome to python programming ", "long"))
''' Scenario: 1
checking whether the word "Python" available in the big string.
Expected result: True
Actual result: True
'''
''' Scenario: 1
checking whether the word "long" available in the big string.
Expected result: False
Actual result: True
'''