Thanks very much. Deepcopy works fine, as does reversed(b). I thought I
needed the index number but I didn't.
Duncan Booth wrote:
> manstey wrote:
>
> > for index in reversed(range(0,len(a)-1)):
> >if '75' in b[index][1]:
> > b[index][1].remove('75')
> > b[index][1].append('99')
manstey wrote:
> for index in reversed(range(0,len(a)-1)):
>if '75' in b[index][1]:
> b[index][1].remove('75')
> b[index][1].append('99')
>
What on earth is all that messing around in the for loop intended to do? If
you want a range from len(a)-2 to 0 inclusive then just do it i
Hi,
if u check the id's of a and b lists and also its elements, you will
obeserve that the id's of a and b have changed but id's of their
elements have not changed.
If you make a deep copy of the list a and then make your changes in
that list, it shud work. this can be done using the copy module
I can't figure out why my code is not working. I thought I had the list
copied correctly:
Here is my code:
a=[[u'HF', []], [u')F', [u'75']], [u'RE', []], [u'C', []]]
b=a[:]
for index in reversed(range(0,len(a)-1)):
if '75' in b[index][1]:
b[index][1].remove('75')
b[i