Python Forum

Full Version: Function
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Code:
def h():
    print('hey')
print(h(),'hello')
Output:
Output:
hey None hello
Please someone explain me the output. I am a beginner and have just started learning python.
every function returns something. if it does not return anything explicitly, it returns None. That is the case with your function h - it does not return anything explicitly, so it return None
on line 3, it first call function h, it prints hey - that is the first line of the output and returns None, so your print function actually gets a 2 element tuple - None, 'hello' and prints it (that is the second line of the output)
(Feb-01-2018, 07:11 PM)buran Wrote: [ -> ]every function returns something. if it does not return anything explicitly, it returns None. That is the case with your function h - it does not return anything explicitly, so it return None
on line 3, it first call function h, it prints hey - that is the first line of the output and returns None, so your print function actually gets a 2 element tuple - None, 'hello' and prints it (that is the second line of the output)

Thank you :) Also, will take care of the format in future. :)