Please could someone show me what I am doing wrong? Why is this not working? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Please could someone show me what I am doing wrong? Why is this not working?

I have been trying the Search Engine challenge on the Python for beginners course, and I got stuck. I tried the code on an IDE and it worked well. Why isn't it working in this IDE? Here is the code; #your code goes here def search(text, word): if word in text: print("Word Found") else: print("Word Not Found") print(search(input(), input()))

8th Aug 2021, 9:47 PM
Victory Amadi
Victory Amadi - avatar
6 Answers
+ 6
The reason sololearn doesn't accept it is that your print statements are not identical to the one asked for (capitalisation). There is a bigger issue that sololearn does not check for: the task is to write a function that *returns* the result, not *prints* it. https://code.sololearn.com/cuoxFt377sb6/?ref=app
8th Aug 2021, 10:05 PM
Simon Sauter
Simon Sauter - avatar
+ 2
search() doesn't return anything, that's why it outputs "None". Try just: search(input(), input())
8th Aug 2021, 9:48 PM
Slick
Slick - avatar
+ 1
It all matters about how the input is given and what the exact output is. Please give examples of both
8th Aug 2021, 9:57 PM
Slick
Slick - avatar
+ 1
I see my error. Thank you very much
8th Aug 2021, 10:16 PM
Victory Amadi
Victory Amadi - avatar
0
I tried that, but it didn't work. Like, it worked in the sense that when you enter a word not in the text, it prints "word not found", and when you enter a word in the text it prints "word found" , but why isn't it correct in the eyes of Solearn? I want to move on.
8th Aug 2021, 9:56 PM
Victory Amadi
Victory Amadi - avatar
- 2
Victory Amadi, def search(text, word): for w in text: if w == word: print("Word Found") return print("Word Not Found") search(input().split(" "), input()) Look at the above solution. "Don't forget to keep proper indentation." Input: hello world to everyone world Output: Word Found DHANANJAY PATEL
9th Aug 2021, 9:18 AM
DHANANJAY PATEL
DHANANJAY PATEL - avatar