0
Why does my code give 2 outputs when it's supposed to be only 1 output
The code is text = input() word = input() def search (): if word in text: print("Word found") else: print("Word not found") print(search()) The problem is this let's say the input is Sololearn is good is The output answers word found but in the second line of the output it says none even though it's not supposed to be there, what should I do?
4 Respostas
+ 5
Hi! Simple delete print() and leave search()
+ 1
Da GD Bot
Because you are not returning anything in function so if you print function then None will return.
So don't print function just call function like:
search ()
+ 1
def search ():
if word in text:
return ("Word found")
else:
return ("Word not found")
print(search())
replaced print with return will give you word found / word not found based on input.
+ 1
Aight it's done thanks guys