list problem 4 newbie
manstey
manstey at csu.edu.au
Mon Jun 26 19:02:42 EDT 2006
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')
> >
>
> 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 in range
> directly (and did you really mean not to look at the last element?), if you
> actually just wanted to iterate through b in reverse, then just iterate
> through b in reverse:
>
> b = copy.deepcopy(a)
> for element in reversed(b):
> if '75' in element[1]:
> element[1].remove('75')
> element[1].append('99')
More information about the Python-list
mailing list