Because there are two print statements . First, it is inside the function, and the second is outside the function. When a function does not return any thing, it returns None.
Use the return at the end of the function to return a value.
eg:.
Do not return a value.
>>> def test1(): ... print "In function." ... >>> a = test1() In function. >>> print a None >>> >>> print test1() In function. None >>> >>> test1() In function. >>>
Use return statement
>>> def test(): ... return "ACV" ... >>> print test() ACV >>> >>> a = test() >>> print a ACV >>>
source share