Moving Places, Subtracting from slices/lists

Mark Sargent powderkeg at snow.email.ne.jp
Thu Jun 2 03:12:44 EDT 2005


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 "<stdin>", line 3, in ?
TypeError: list indices must be integers

How do I get that x to be an integer b4 it is entered into the indice.? 
Cheers.

Mark Sargent.



More information about the Python-list mailing list