Answer the question
In order to leave comments, you need to log in
What is the error (why is the function exiting 5 and not 7)?
x=5
def funA(x,y):
x=7
return x
funA(x,4)
print x
Answer the question
In order to leave comments, you need to log in
Read about references, objects, variable scope, and how to pass parameters to a function.
What we see in the code: we
created an object with the value "5" and assigned a reference to it to the variable "x"
def funA(x,y):
x=7
return x
>>> x=5
>>> def funA(x,y):
x = 7
return x
>>> funA(x,4)
7
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question