Why is "None" printed after my function's output?
function, python
Solution
It's the return value of the function, which you print out. If there is no return statement (or just a `return` without an argument), an implicit `return None` is added to the end of a function.
You probably want to return the values in the function instead of printing them:
def jiskya(x, y):
if x > y:
return y
else:
return x
print(jiskya(2, 3))
Problem
I tried writing this code: ``` def smaller(x, y): if x > y: print(y) else: print(x) print(smaller(2, 3)) ``` I got this result: ``` >>> 2 None ``` Where did the `None` come from? What does it mean? See also The accepted answer explains the importance of `return`ing a value from the function, rather than `print`ing it. For more information, see What is the purpose of the return statement? How is it different from printing?. To understand the `None` result itself, see What is a 'NoneType' object?. If you are `print`ing inside the function in order to see multiple values, it may be better to instead collect those values so that they can be printed by the calling code. For details, see How can I use `return` to get back multiple values from a loop? Can I put them in a list?.