#Using print instead of return , gives output none in last line | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

#Using print instead of return , gives output none in last line

#Using print instead of return , gives output none in last line. def add_numbers(x, y): total = x + y return total print("This won't be printed") print(add_numbers(4, 5))

28th Apr 2020, 1:26 PM
Kalpna Kushwaha
Kalpna Kushwaha - avatar
2 Answers
+ 1
If you want return value, you may think using that, print (add_numbers (4, 5)) Otherwise, if you will print something inside function, do that, add_numbers(4, 5) Every function in python returns something whether it be a value or None.
28th Apr 2020, 1:35 PM
Mustafa K.
Mustafa K. - avatar
+ 1
The line with „this wont be printed“ wont be prinzed, because after the return statement the function ends....
28th Apr 2020, 2:05 PM
Alexander Thiem
Alexander Thiem - avatar