+ 1
Search Engine Problem
Hello! I'm having trouble with the Search engine problem at the end of Python for beginners. I am returning "Word not found" on every input for text and word. Here is my code: text = str(input()) word = str(input()) def search(text,word): if word == text: print("Word found") else: return("Word not found") print(search(text, word))
2 Answers
+ 1
In your function search in if you have print and in else return. Please read the task and think about it again.
Hint:
In the text you can have more than one word.
+ 1
text is a line of string.
Word is a single word, which should be find existence in text. There are not equal..
Ex:
'Hello World'
'World'
'World' is in "Hello World" must return true but see they both are not same strings..
and use both times return instead of print in function.
Hope it clears..