5
When I studied Pascal remember that my teacher explained that to pass an argument by reference it was necessary to put var
in front of the variable, in the function/procedure parameters.
Example:
function exemplo(var, a: real):real;
In Python what you need to do to make it happen?
The idea is to have a variable defined at the beginning of the program, change it within the function, and change its value outside the function without using return
.
If the idea is to change the value of an external variable, use the
return
and assign again to the variable. Explicit is better than implicit in Python.– Woss
It is that to get to the function that changes this value you need to go through other 3 or 4. Then you would have to do retreat in all these?
– Manolloz
Possibly. If you want, you can join the chat we can discuss the code.
– Woss
Did any of the answers solve your question? Do you think you can accept one of them? Check out the [tour] how to do this, if you haven’t already. You would help the community by identifying what was the best solution for you. You can accept only one of them. But you can vote on any question or answer you find useful on the entire site (when you have enough score).
– Maniero