Python Forum
[split] Why is there an output of None - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: [split] Why is there an output of None (/thread-41200.html)



[split] Why is there an output of None - akbarza - Nov-27-2023

hi
I have a small question, but I did not know if i must open a new thread for it or not, so I ask here:
in the below code :
class Request:
    def send(self):
        print('Sent')

        
http_request=Request()
print(http_request.send())
after running in idle, the output is:
Output:
Sent None
what is this None and what is the reason for it?
I think the output must be send only.
thanks


RE: error occuring in definition a class - deanhystad - Nov-27-2023

None is an object that signifies no value. None is returned by functions/methods that don't have a "return" statement. Request.send() does not have a return statement, so it returns None. Your program prints the return value of http_request.send(), so it prints "None".