Question:
In this sentence 'My favourite cricketer is Dhoni, Kohli and Rohit' find the word 'Dhoni'
Code:
word = 'My favourite cricketer is Dhoni, Kohli and Rohit'
key = 'dhoni'
word = word.lower()
key_length = len(key)
print(key_length)
word_length = len(word)
for i in range(word_length):
if key == word[i:i+key_length]:
print('found')
break
else :
print("not found")
Output:

Top comments (0)