Because there are two print statements. First is inside function and second is outside function. When a function doesn't return anything, it implicitly returns None
.
Use return
statement at end of function to return value.
e.g.:
Return None
.
>>> 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
>>>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…