Fredrik Lundh wrote: >Elliot Temple wrote: > > > >>btw hotcat[:] is a *copy* of hotcat, so just leave out "[:]" >> >> > >when you want to modify the thing you're looping over, you need >to be careful. looping over a copy is often a good idea (see the >Python tutorial and the FAQ for more on this). > > > Yes, I saw that, and that's why I was using the copy form in the loop...thanx for verifying this.
>>enumerate is a function that adds indexes to a list. observe: >> >> > > > >>>>hotcat = ['roof', 'roof', 'roof'] >>>>for index, word in enumerate(hotcat): >>>> if word == 'roof': del hotcat[index] >>>>print hotcat >>>> >>>> >['roof'] > >if I understand the OP correctly, he wants to *move* the "roof" to the >end of the string. > > correct... > try: > hotcat.remove("root") > hotcat.append("root") > except ValueError: > pass > >is most likely the fastest way to do that. > ></F> > > > will give it a blast...thanx > > > Cheers. Mark Sargent. -- http://mail.python.org/mailman/listinfo/python-list