+ 4

Search engine - Python Beginners

Hi All, This is what I put as my answer. Any help would be much appreciated. text = input() word = input() def search(text, word): if word in text: print("word found") else: print("word not found") search(word, text) print(search(text, word))

8th Jul 2022, 10:16 PM
Reiss
13 Respostas
+ 3
Instead of last 2 lines just put search(text, word) Then think about your mistake...
8th Jul 2022, 10:37 PM
Jayakrishna 🇮🇳
+ 2
No. You have 2time function calls, why? And order of parameters is correct in 2 call. Instead of search( word, text) print( search( text, word)) Just put search(text, word)
8th Jul 2022, 10:45 PM
Jayakrishna 🇮🇳
+ 2
Ok. I checked the description and it asked there is "The search() function should return "Word found" if the word is present in the text, or "Word not found", if it’s not." "Word" W is capital letter.. but you are using small letter w... use capital W, this change works fine.Reiss But it asked to use return statement so correct way by it using return is text = input() word = input() def search(text, word): if word in text: return "Word found" else: return "Word not found" print( search(text, word) ) #both ways works....
8th Jul 2022, 11:03 PM
Jayakrishna 🇮🇳
+ 2
That worked thanks Jayakrishna. I’ve nearly completed the course but i think im going to go through it again before moving on to the next level up in Python.
8th Jul 2022, 11:13 PM
Reiss
+ 2
You're welcome..
9th Jul 2022, 1:57 PM
Jayakrishna 🇮🇳
+ 1
So you mean i should take out my else statement?
8th Jul 2022, 10:40 PM
Reiss
+ 1
Why "word in word" ? It's always true.. remove it. I said about only last 2 statements of your previous original code.
8th Jul 2022, 10:47 PM
Jayakrishna 🇮🇳
0
text = input() word = input() def search(text, word): if word in text: print("word found") elif word in word: print("word found") else: print("word not found") search(word, text)
8th Jul 2022, 10:44 PM
Reiss
0
text = input() word = input() def search(text, word): if text in word: print("word found") else: print("word not found") search(text, word) Still not working. Can you tell me the answer because I’m not getting this, maybe the. I will understand.
8th Jul 2022, 10:57 PM
Reiss
0
text = input() word = input() def search(text, word): if word in text: print("word found") else: print("word not found") search(text, word)
8th Jul 2022, 11:01 PM
Reiss
0
How to i add an objcte
10th Jul 2022, 9:56 AM
Natasha Clatk
0
Great
10th Jul 2022, 5:02 PM
Anser7
0
Hi all, solution for search engine is: text = input() word = input() def search(text, word): if word in text: return("Word found") else: return("Word not found") print(search(text, word))
18th Sep 2022, 11:38 AM
David Herceg
David Herceg - avatar