+ 4

Why this Program take a list argument as call by reference .if i want call by value when function call how can achieve that .

The any change in list inside function affect the list in outside why ? https://code.sololearn.com/cqWbZTtwWLci/?ref=app

10th Nov 2018, 12:10 AM
Programmer Raja
Programmer Raja - avatar
2 Respostas
+ 3
You'll have to copy the list yourself. In your function you can do `b = b.copy()` Python passes everything "by reference" unless it's a primitive type (numbers, strings, booleans). That is to avoid unneccessary copying!
10th Nov 2018, 12:50 AM
Schindlabua
Schindlabua - avatar
+ 4
This is just an idea: the argument’s type is a memory adress, method p change the values contains in this adress, but the argument not change, its the same adress https://code.sololearn.com/c2l6WHeM6qPJ/?ref=app
10th Nov 2018, 12:56 AM
AntonioJFN
AntonioJFN - avatar