0
Why is there "None" at the end?
Welcome, I'm currently trying to run a programme that will search for a word in text. I wrote a programme that is shown below. The problem is, that output instead of being one print, it's this print plus "None". Can anyone explain to me why it's outputing this additional "None"? And I need it as function, that's why it has def in it. text = input() word = input() def search(x,y): if y in x: print("Word found") else: print("Word not found") print(search(text, word))
2 Answers
+ 5
print() function doesn't return anything, hence it returns None.
The issue is that you print inside if the function and then print it again in the last line.
One way to solve this, is using "return" i the function instead of printing