>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
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
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
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
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
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
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']