0
help my code does not iterate
The code takes text and word as input and passes them to a search() function. should return "Word found" if the word is text, or "Word not found" if it is. https://code.sololearn.com/cYjOUfPLAjv8/?ref=app
9 ответов
+ 2
Try this:
def search (x,y):
for i in x:
if i == y:
return ("Word found")
else:
return ("Word not found")
text = input()
word = input()
print(search(text, word))
i only remove split from your code hope it helps you ^_^
+ 2
You don't need to split() anything and you don't need a loop. Just check:
if word in text
+ 1
Thanks
0
the challenge asks me this: You are 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 is not. input example "This is incredible" "amazing" output example found word Define the function search(), so that the given code works as expected.
0
and my code only delivers the second output but it doesn't deliver the first and to meet the challenge I must deliver both
0
Again: You do not need the loop, you only need to test "if word in text" and return the corresponding string.
0
Ok
0
For next time please, avoid wriring code in the post tags, tags has their own purpose for the forum's search engine.
https://code.sololearn.com/W3uiji9X28C1/?ref=app
0
Thanks for the support of both of you. I really attribute the information to myself. I realized that you were drowning me in the gorilla.