+ 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))
13 Respostas
+ 3
Instead of last 2 lines just put
search(text, word)
Then think about your mistake...
+ 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)
+ 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....
+ 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.
+ 2
You're welcome..
+ 1
So you mean i should take out my else statement?
+ 1
Why "word in word" ? It's always true.. remove it.
I said about only last 2 statements of your previous original code.
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)
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.
0
text = input()
word = input()
def search(text, word):
if word in text:
print("word found")
else:
print("word not found")
search(text, word)
0
How to i add an objcte
0
Great
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))