If I have a list of numbers, and I want to increment them using a for loop, why isn't this working:
>>> list=[1,2,3,4,5]
>>> for num in list:
... num=num+1
...
>>> list
[1, 2, 3, 4, 5]
I expected to get [2,3,4,5,6].
I know I can get around this by doing
>>> newlist=[]
>>> for num in list:
... newlist.append(num+1)
...
>>> newlist
[2, 3, 4, 5, 6]
>>>
but there must be an easier way.