Removing a particular index from a list
Steve Holden
steve at holdenweb.com
Thu Mar 22 09:11:14 EDT 2007
Srikanth wrote:
> Hi,
>
> list.remove(item) removes the first item from the list, but how do I
> say to remove a particular index from a list without using it's value?
>
> Let's say I have 4 items in my list as
>
>>>> li = ["sri", "s", "srikanth", "s"]
>
> And if I want to remove the last item ("s"), how do I remove it?
> li.remove(-1) doesn't do it. This is my problem.
>
>>> li = ["sri", "s", "srikanth", "s"]
>>> del li[-1]
>>> li
['sri', 's', 'srikanth']
>>>
regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://del.icio.us/steve.holden
Recent Ramblings http://holdenweb.blogspot.com
More information about the Python-list
mailing list