let's say i have a list
a = [1,2,3]
I would like to increase each item in this list. I want to do something syntactically simple, like
for item in a:
item += 1
but in this example python uses only the value item, not its actual reference, so when I finished with this loop ait still returns [1,2,3] instead of [2,3,4]. I know I can do something like
a = map(lambda x:x+1, a)
but this really is not suitable for my current code, and I would not want to rewrite it: - \
source
share