+ 1

You’re working on a search engine. Watch your back Google! The given code takes a text and a word as input and passes them to

text = input () word = input() def search(text,word): If word==text: Print("Word found) else: print("Word not found")

13th Apr 2022, 12:25 PM
Alabi Ayodele
Alabi Ayodele - avatar
7 Respuestas
+ 3
You need to use in operator to determine whether or not a string is a substring of another string. == is used for comparing values. Also, you're missing to call search function at the end.
13th Apr 2022, 12:37 PM
Simba
Simba - avatar
+ 3
Alabi Ayodele the code defines the search() function but never calls it. In the search() function, it mistakenly compares for an exact match of the two strings, whereas the task is to determine whether the word is found within the text. The text may have other words in it as well. Print should not be capitalized.
13th Apr 2022, 12:40 PM
Brian
Brian - avatar
+ 2
Alabi, Please note the use cases of relevant tags in the post. It's important because it is used by SoloLearn search engine to classify topic of discussion, and proper tags allows better searchability. https://code.sololearn.com/W3uiji9X28C1/?ref=app
13th Apr 2022, 1:40 PM
Ipang
+ 2
Alabi Ayodele For unexplained reasons, you replaced the text "Word found" with a recursive call. Restore the text and it should work.
13th Apr 2022, 2:35 PM
Brian
Brian - avatar
+ 1
Alabi Ayodele that is better, but still it needs to call the function. Add this line: search(text, word)
13th Apr 2022, 1:44 PM
Brian
Brian - avatar
0
text = input() word = input() def search(text, word): if word in text: print(search (text, word)) else: print("Word not found")
13th Apr 2022, 1:42 PM
Alabi Ayodele
Alabi Ayodele - avatar
0
text = input() word = input() def search(text, word): if word in text: print(search(text, word)) else: print("Word not found") search(text, word) # I did this still not working
13th Apr 2022, 2:04 PM
Alabi Ayodele
Alabi Ayodele - avatar