let's say I have a list
a = [1,2,3]
I'd like to increment every item of that list in place. I want to do something as syntactically easy as
for item in a:
item += 1
but in that example python uses just the value of item
, not its actual reference, so when I'm finished with that loop a
still returns [1,2,3] instead of [2,3,4]. I know I could do something like
a = map(lambda x:x+1, a)
but that doesn't really fit into my current code and I'd hate to have to rewrite it :-\