Re: Moving Places, Subtracting from slices/lists

2005-06-03 Thread Mark Sargent
>what does [hotcat[1]] do.? > > > ah, quite simple really, adds roof to the end of hotcat...thanx.. Mark Sargent. -- http://mail.python.org/mailman/listinfo/python-list

Re: Moving Places, Subtracting from slices/lists

2005-06-02 Thread Mark Sargent
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

Re: Moving Places, Subtracting from slices/lists

2005-06-02 Thread Mark Sargent
Dennis Lee Bieber wrote: >On Thu, 02 Jun 2005 16:12:44 +0900, Mark Sargent ><[EMAIL PROTECTED]> declaimed the following in >comp.lang.python: > > > >>How do I get that x to be an integer b4 it is entered into the indice.? >>Cheers. >> >> >> > If you really want the index, ask for the

Re: Moving Places, Subtracting from slices/lists

2005-06-02 Thread Fredrik Lundh
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). > enumerate is a function that adds

Re: Moving Places, Subtracting from slices/lists

2005-06-02 Thread Elliot Temple
On Jun 2, 2005, at 12:12 AM, Mark Sargent wrote: > Hi All, > > getting closer, me thinks. > > hotcat = ['Cat', 'roof', 'on', 'a', 'hot', 'tin'] for x in hotcat[:]: > ... if x == 'roof': hotcat.insert(6,x) > ... del hotcat[x] > ... > Traceback (most recent call last): > Fi

Re: Moving Places, Subtracting from slices/lists

2005-06-02 Thread Mark Sargent
Hi All, getting closer, me thinks. >>> hotcat = ['Cat', 'roof', 'on', 'a', 'hot', 'tin'] >>> for x in hotcat[:]: ... if x == 'roof': hotcat.insert(6,x) ... del hotcat[x] ... Traceback (most recent call last): File "", line 3, in ? TypeError: list indices must be integers How do I get

Moving Places, Subtracting from slices/lists

2005-06-01 Thread Mark Sargent
Hi All, playing around with the tut now. How can I get this code to remove the original instance of 'roof'.? >>> hotcat = ['Cat', 'roof', 'on', 'a', 'hot', 'tin'] >>> for x in hotcat[:]: ... if x == 'roof': hotcat.insert(6,x) ... >>> hotcat ['Cat', 'roof', 'on', 'a', 'hot', 'tin', 'roof']