[Solved] Why does this function return this value? [duplicate]


The default return of the method will be None. If you perform the following:

res = output()

and print out res, it will be None. By default, None is always returned when not specifying a return.

>>> def output():
...     print "Hello, world!"
...
>>> res = output()
Hello, world!
>>> res
>>> type(res)
<type 'NoneType'>

However, you will still get something printed to screen, because the print statement will run when the method is called.

solved Why does this function return this value? [duplicate]