return | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

return

what is RETURN on python? i can not understand it.

9th May 2018, 7:13 AM
Tshepiso Mokoena
Tshepiso  Mokoena - avatar
4 Answers
+ 5
A function is made to do some task and then it "returns" the result. For example the add() function: def add(x, y): sum = x + y # the summation task return sum # will return the sum print(add(5, 7)) # will print the "return" value i.e., 12
9th May 2018, 7:23 AM
777
777 - avatar
+ 3
THNAKS
9th May 2018, 7:27 AM
Tshepiso Mokoena
Tshepiso  Mokoena - avatar
+ 3
I want add that its NOT necessary that an function return something (though in python in this case return None special value)
9th May 2018, 9:02 AM
KrOW
KrOW - avatar