+ 1
How to do the Search engine challenge in python?It prints”word found” and then it prints “none” in the next line.
text = input() word = input() def search(x,y): if word in text: print("Word found") else: print("Word not found") print(search(text, word))
6 odpowiedzi
+ 2
text = input()
word = input()
def search(x,y):
if word in text:
print("Word found")
else:
print("Word not found")
search(text, word)
+ 3
Joel Sebastian Jijo
If you have already printed value in function then no need to print that function because you may also get None because of no return statement.
Note : If you don't return anything in function and you print that function then you may get None.
So you just need to call function in this case.
You can also do this:
text. = input()
word = input()
def search(text, word):
if word in text:
return "Word found"
else:
return "Word not found"
print(search(text, word))
+ 2
you have a print statement in your last line but your function doesn't return anything so remove the last print function
+ 1
Yeah thanks. I should have used return.The print(search(text,word)) was already given in the question.
0
Thnx i did it and it worked.
0
the alternative fix would be to return the result string, or even True or False (by modifying your print statement with a ternary like argument)