+ 3
Hello. I don't in understand clearly about returning from function. Could you explain me more?
2 Respuestas
+ 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.
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.