Why does this work?


I have no idea why does this code works. This return 18 which is the sum of m and n but, how does pyton knows to change the values of m and n for x and y?

m = 5
n = 13
def add_function(x, y):
    suma = (x + y)
    return suma
print add_function(m, n)


You simply assigned the function which had two parameters with values, which is right. But those values were assigned to m and n.

Actually, this works in many, if not all, scripting languages. :slight_smile:


Its kind of confusing, but i guess its really useful once you learn how to use them properly. thanks for the answer :smiley:


You're welcome.

code on!


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.