+ 1
Search engine project in python for beginners.
def search(sentence,word): for i in s: if (i==word): return True else: return False s=input() word=input() if (search(s,word)): print ("Word found") else: print ("Word not found") The code above always prints "word not found". Plz help.
1 Réponse
+ 1
Simar Singh
Don't use loop and compare value just do this
if word in s:
return True
else:
return False
When you do " for i in s: " then it will compare "each character of given sentence with word" not "each word of given sentence with word".