+ 1

Python search engine

Guys Anybody know how write this!! 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

29th Mar 2021, 1:31 PM
Emre Sarıcan
Emre Sarıcan - avatar
20 Antworten
- 7
Why is using return mandatory, but not directly using print("Word Not Found")?
21st May 2021, 6:09 PM
Shyam prasad
Shyam prasad - avatar
+ 14
Emre Sarıcan You need to check word in text but you didn't. Solution:- #That is mine try text = input() word = input() def search(text, word): #for i in word: if word in text: a ="Word found" return a else: b = "Word not found" return b print(search(text, word))
29th Mar 2021, 1:35 PM
A͢J
A͢J - avatar
+ 9
def search(text,word): if word in text: print("Word found") else: print("Word not found") return (search) text = input() word = input() search(text, word) This worked for me try it out.
8th Aug 2021, 6:16 PM
Janani S
+ 2
There are two problems 1 - Indentation 2 - you are taking input as word but passed in function as Word. So try this text = input() word = input() def search(text, word): if word in text: print("Word found") else: print("Word not found") search(text, word)
23rd Aug 2021, 5:52 AM
Raghvendra Pratap Verma
Raghvendra Pratap Verma - avatar
+ 1
def seacrh(text,word) : if word in text : print ('Word found') else: print('Word not found') text = input() word = input() seacrh(text,word) done..!
6th Mar 2022, 3:00 PM
Nikhila
0
Emre Sarıcan One more thing you should always call function after declaration otherwise you will get error.
29th Mar 2021, 1:41 PM
A͢J
A͢J - avatar
0
I understood thank you for all
30th Mar 2021, 12:04 PM
Emre Sarıcan
Emre Sarıcan - avatar
0
Emre Sarıcan Most welcome 🙂 Happy coding 👍
30th Mar 2021, 12:59 PM
❤️😍Prerana😍❤️
❤️😍Prerana😍❤️ - avatar
0
text = input() word = input() def search(text, word) if word in text: print("Word found") else: print("Word not found") print(search(text, word)) Important points to note: Always declare variables before creating function
1st Apr 2021, 10:07 AM
SathyaPhaneeshwar Donthi
SathyaPhaneeshwar Donthi - avatar
0
#Here is my code try it: def seacrh(text,word) : if word in text : print ('Word found') else: print('Word not found') text = input() word = input() seacrh(text,word)
29th May 2021, 11:37 AM
Vraj Soni
Vraj Soni - avatar
0
I still cant get it
30th Sep 2021, 8:48 AM
ABRAHAM MUBARAK
ABRAHAM MUBARAK - avatar
0
text = input() word = input() def search(text,word): if word in text: print("Word found") else: print("Word not found") search(text, word)
2nd Oct 2021, 6:00 AM
Sigiti Mohan Rao
Sigiti Mohan Rao - avatar
0
you can use this code text = input() word = input() def search(text, word): if word in text: a = "Word found" return a else : a = "Word not found" return a print(search(text, word))
21st Jan 2022, 3:30 PM
YOUSSEF EL FAKKANY
YOUSSEF EL FAKKANY - avatar
26th May 2022, 11:55 AM
Hrithika Reddy
Hrithika Reddy - avatar
0
text = input() Word = input() def Search(text,word): if word in text: a = "Word found" return à else b = "Word not found" return b print(search(text, word))
19th Aug 2022, 6:05 PM
Souleymane Ndiaye
Souleymane Ndiaye - avatar
0
text = input() word = input() def search(text, word): if word in text: print("Word found") else: print("Word not found") search(text, word) #just remove the print, by me :D
16th Apr 2023, 2:43 AM
Muhammad Mustafa Bongalon
Muhammad Mustafa Bongalon - avatar
2nd May 2023, 6:33 AM
Akshat Popat
Akshat Popat - avatar
- 2
Emre Sarıcan Here is my code try it: def seacrh(text,word) : if word in text : print ('Word found') else: print('Word not found') text = input() word = input() seacrh(text,word)
30th Mar 2021, 12:46 AM
❤️😍Prerana😍❤️
❤️😍Prerana😍❤️ - avatar
- 2
Thank youi
2nd Oct 2021, 5:17 PM
ABRAHAM MUBARAK
ABRAHAM MUBARAK - avatar
- 3
That is mine try text = input() word = input() print(search(text, word)) def search(): for i in word: if i == word: a ="Word found" return a else: b = "Word not found" return b
29th Mar 2021, 1:32 PM
Emre Sarıcan
Emre Sarıcan - avatar