Search engine code project intro to Python
I think I have the right answer, but my output is "word not found." How can I change that?
Use a return statement instead of printing. So that it only prints once.
Please show your code. Pay attention to the spelling of the output strings: They must be exactly the same as in the task description.
Bracha, You need to search the input string to see if it contains the input word. If it does then print the word found text. If you show your attempt we can help steer you.
Bracha, your so close… Look at your calling of the function though, you define the function as “word, text” but are calling it with “text, word”.
Bracha, as you are soo close, here’s it working - look at the difference (using return instead of print) def search(text, word): if word in text: return('Word found') else: return('Word not found') text = input() word = input() print(search(text, word))
As your function didn’t return anything, the print statement had nothing to print (that’s why it was printing ‘None’) Hopefully that makes sense?
Yes thank you DarX
this was my attempt. When I look at the comments everyone succeeded with the same answer def search (word,text): if word in text: print ("Word found") else: print ("Word not found") text = input() word = input() print(search(text, word)) my output: Word found None
DavX I switched it to (word,text)but I'm getting the same result