I've searched regarding this and came across list returning functions but I still don't understand it.
I'm trying to understand why Print function to another function returns the following :
Happy Birthday
Happy Birthday
None None
My Code:
def happy():
print("Happy Birthday")
def main():
print(happy(), happy())
main()
I know that function returns special object called :None. But I'm just trying to understand why it does so?
Every function always returns a value. If you don't explicitly return a value, and the function just gets all the way to the end, then it automatically returns None. Your function happy doesn't have any return statement, so at the end of the function, it automatically returns None.
when you call to happy() returns none, so after each function is called you are printing
print(None, None)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With