+ 6
How does the "return" function work in python 3? ._.
I am beging to code so some of these functions don't click yet. But I would love to learn how they do! Thank you!
6 Réponses
+ 3
return is simple
def add(x,z):
a=x
b=z
c=a+b
return c
if I call
add(2,3)
it will return c.. which is 5
+ 5
OMG. It all clicks now!! Thank you!!!! ^^
+ 2
does that make sense?
+ 2
So that means I would then disclose a and B because they aren't being returned to the 'add'?
+ 2
well that would be up to you, the variables are just an example.. you can return anything. here is another
def shout():
return print("ahhhhh!")
shout()
return is whatever information you want to get back from your function
+ 1
It's a great feeling when things click.. functions are fun.. if you haven't played with for loops, I would go there next. very useful