+ 3

Hello. I don't in understand clearly about returning from function. Could you explain me more?

29th Aug 2016, 1:21 AM
MA DUONG
MA DUONG - avatar
2 Respostas
+ 6
in a function sometimes you need get a value from that function so you have to return it from it. example: def add(a,b): c=a+b def add2(a,b): c=a+b return c result = add(10,20) result2 = add2(10,20) print("result "+result) print("result2 "+result2) "result " "result2 30" in the first case the function don't return the result so it is lose and the second function has a return so you can get it and you can use it then.
29th Aug 2016, 2:18 AM
Adrian Manrique
Adrian Manrique - avatar
0
"return var" is like "print(var)" but in the most of cases you have to put "return" if you want to use it in other functions.
26th Sep 2016, 11:06 PM
Cairo
Cairo - avatar