0
Why this is returning none at last ?
7 Answers
+ 2
Aakash Mitra do this,
search(text, word)
instead of
print(search(text, word))
_______________________
For print to print some value (other than None), search function needs to return a value.
+ 4
Because you are printing a function that contains a print() function. The output of printing print() is None.
If you are going call your function by putting it in a print() function, then don't have your function print the word results, just return them. E.g.
if word in text:
return "Word found"
else:
return "Word not found"
then print(search(text, word)) should work.
Alternatively, if your function says
if word in text:
print("Word found")
else:
print("Word not found")
Then simply call the function by saying
search(text, word)
And that should also work.
+ 1
Because search function doesn't returns a value and so printing it prints None by default.
just call the function instead of printing it as well.
0
Abhay so now what i can do to solve it
0
Aakash Mitra just call the function .
0
Abhay sorry but can you explain me in a easier way or explain me by making it yourself
0
Abhay Thanks bro