You can not.
You will need to figure out another way to track things. I think you can probably structure your code to use a mutable data type , like listeither dict, or perhaps create a custom one:
class MutableInt:
def __init__(self, value=0):
self._value = value
def __add__(self, other):
self._value += other
def __repr__(self):
return str(self._value)
mutable_int = MutableInt(4)
print(mutable_int)
def addOne(mutable_int):
mutable_int += 1
addOne(mutable_int)
print(mutable_int)
source
share