How to make search engine using python vide | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How to make search engine using python vide

Search Engine 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 a function called search(). The search() function should return "Word found" if the word is present in the text, or "Word not found", if it's not. Sample Input "This is awesome" "awesome" Sample Output Word found Define the search() function, so that the given code works as expected.

13th Apr 2021, 8:47 AM
Jay Bhamare
Jay Bhamare - avatar
7 Answers
+ 7
# Search engine text = input() a = text.split() word = input() def search(): if word in text: print("Word found") else: print("Word not found") search()
27th Jun 2021, 5:31 AM
Jay Bhamare
Jay Bhamare - avatar
+ 4
Try it in this way text = str(input()) word = str(input()) def search(text,word): text = text.split(' ') if word in text: return("Word found") else: return("Word not found") print(search(text,word))
27th Jun 2021, 5:50 AM
Aysha
Aysha - avatar
+ 3
Hint: use the for loop and also use split method
13th Apr 2021, 9:22 AM
Aysha
Aysha - avatar
+ 2
text = str(input()) word = str(input()) def search(text,word): text = text.split(' ') if word in text: return("Word found") else: return("Word not found") print(search(text,word)) very good thx
17th Dec 2021, 9:36 PM
Atlas Tiger
Atlas Tiger - avatar
0
Jay Bhamare Show your attempts
13th Apr 2021, 9:18 AM
A͢J
A͢J - avatar
0
or we can do it b using for loop text = str(input()) word = str(input()) def search(text, word): for i in text: if word in text: return("Word found") else: return("Word not found") break search(text, word)
6th Dec 2022, 10:52 AM
Muhammad Ghufran
Muhammad Ghufran - avatar
0
# Search engine text = input() a = text.split() word = input() def search(): if word in text: print("Word found") else: print("Word not found") search()
11th Oct 2023, 9:43 AM
Tiger Muthuvel Pandian fa fa fa fa fa
Tiger Muthuvel Pandian fa fa fa fa fa - avatar