+ 1

Why is my code failing to complete some test cases?

My python code for a search engine project Isn't producing the correct output for the second test case and I can't figure out what is wrong. Any help please? https://www.sololearn.com/learning/eom-project/1157/1022

20th Aug 2021, 8:46 AM
Henry Viyuyi
Henry Viyuyi - avatar
4 ответов
+ 3
Henry Viyuyi We can't see your code through that link so attach your code with question.
20th Aug 2021, 11:05 AM
A͢J
A͢J - avatar
+ 1
Can you please attach your code attempt. The link to the challenge makes my phone crash
20th Aug 2021, 9:03 AM
Rik Wittkopp
Rik Wittkopp - avatar
+ 1
David García Prados the solutions in that thread are wrong. They define a function that *prints* the result. However the task is to write a function that *returns* the result. Those codes will pass the test cases, but only because solo learn only checks the output, it doesn't check whether or not your code produces that output in the right way. [Edit: the answer I'm referring to is deleted. I'll let this answer stay anyway since it seems that a lot of people use print instead of return in the function definition for this task. ]
20th Aug 2021, 10:03 AM
Simon Sauter
Simon Sauter - avatar
+ 1
Ok, Simon. Added my solutions. Using lambdas: text = input() word = input() search = lambda text, word : 'Word found' if word in text else 'Word not found' print(search(text, word)) Without lambdas: text = input() word = input() def search(text,word): return 'Word found' if word in text else 'Word not found' print(search(text, word))
20th Aug 2021, 10:07 AM
David García Prados