+ 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))

19th Aug 2022, 1:19 PM
Tom Bright
Tom Bright - avatar
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.
19th Aug 2022, 1:24 PM
JaScript
JaScript - avatar
+ 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..
19th Aug 2022, 1:28 PM
Jayakrishna 🇼🇳