I am trying to write a loop that replaces all the elements of the list with elements that are half a big. If the list is [1,2,3,4] the new list should read [0.5,1,1.5,2]. WITHOUT CREATING A NEW LIST!
I tried the following
for i in Glist:
i = Glist[i]/2
Glist.append(i)
And hot an error : list index out of range how to stop the loop?
also tried this:
for i in mylist:
i = i/2
mylist.append(i)
did not work