Scenario: I declared a variable with value 0 in the method; Then I passed this variable as a parameter to another method which is called from first method. Nested method incremented value of the parameter However, the value of the variable remained to be 0
Question: how to update value of the declared variable
Example:
def doSomething(parameter):
number = 0
doIncrement(parameter, number)
print(f'New number is: {number}') // New number is: 0
def doIncrement(param, counter):
for item in param.items(param):
if not isCountable(item):
# do something
else:
counter += 1
print('number in the counter:', counter) // number in the counter: 1
I understand there is no reference that points on counter, so may be should be something similar to C where we using pointer. How is it done in python?