469,288 Members | 2,320 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,288 developers. It's quick & easy.

Moving Places, Subtracting from slices/lists

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

Perhaps a replace or something after the 2nd line of the for function.? hotcat = ['Cat', 'roof', 'on', 'a', 'hot', 'tin']
for x in hotcat[:]:

.... if x == 'roof': hotcat.insert(6,x)
.... hotcat[x:len(x)] = []
....
Traceback (most recent call last):
File "<stdin>", line 3, in ?
TypeError: slice indices must be integers

I feel I'm close to it.

Cheers.

Mark Sargent.

Jul 19 '05 #1
0 833

This discussion thread is closed

Replies have been disabled for this discussion.

By using this site, you agree to our Privacy Policy and Terms of Use.