search engine challenge | Sololearn: Learn to code for FREE!

+2

search engine challenge

what is wrong in my code,I am not getting right answer. Pls. help me out text = input() word = input() def search(text,Word): if Word in text: print("Word found") else: print("Word not found") search(text,Word)

4/13/2021 7:06:52 AM

Sachin

14 Answers

New Answer

+9

text = input() word = input() def search(text,word): if word in text: return("Word found") else: return("Word not found") print(search(text,word)) maybey like thes

+4

Sachin There are two problems 1 - Indentation 2 - you are taking input as word but passed in function as Word. So try this text = input() word = input() def search(text, word): if word in text: print("Word found") else: print("Word not found") search(text, word)

+3

No one likes homework, but your math teacher has given you an assignment to find the sum of the first N numbers. Let’s save some time by creating a program to do the calculation for you! Take a number N as input and output the sum of all numbers from 1 to N (including N). Sample Input 100 Sample Output 5050 Explanation: The sum of all numbers from 1 to 100 is equal to 5050.

+3

text = input() word = input() def search(text, word): #for i in word: if word in text: a ="Word found" return a else: b = "Word not found" return b print(search(text, word)) #not at all!

+2

I know it and i completed it This is how you need to do it Only 6 lines simple text = input() word = input() if word in text: print("Word found") elif word not in text: print("Word not found")

+1

Sachin Why did you write return? Why you don't just call function without return?

+1

The future is now thanks to science No need to write return if you are not returning any value and just printing value.

0

By mistake,but without return there is no output

0

No need to return search(text,Word) otherwise it will become recursive function.Just return. And also you forgot to call the function: https://code.sololearn.com/cu5f8ltJeiJp/?ref=app

0

The future is now thanks to science I never heard it is good to write without any reason.

0

Python functions return None, if there isnt specified return value - same as if u put return without anything or return None or pass

0

Feel like stupid. Tried to find word in search ((( not in text(((

0

text = input() word = input() def search(text, word): #for i in word: if word in text: a ="Word found" return a else: b = "Word not found" return b print(search(text, word))

-2

Hey, help me out pls. I know that this way of solving is overcomplicated, but i wonder why this code not working? if you run it, it will additoinally print "None" on the new line. And i dont get were from it appeared? def search(text, word): if text.count(word) >=1: return(print("Word found")) else: return(print("Word not found")) text = input() word = input() print(search(text, word))