return | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren


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

9th May 2018, 7:13 AM
Tshepiso Mokoena
Tshepiso  Mokoena - avatar
4 Antworten
+ 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 - avatar
+ 3
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 - avatar