Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

How to pass arguments by value in Python function?

In the given code

def foo(x):\n     x = "30"\n     return x\na = ["10"]\nb = foo(a)\nprint "b = ", b\nprint "a = ", a

Are the arguments passed by value in the python function?


1 Answer
Manogna

For given code the output is as follows

b = 30

a = ['10']

In this case, "a" seems to be passed by value, because the value is  unchanged even after the call to the function. So it is clear that the arguments have been passed by value in the python function.

Advertisements

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.