[Python-ideas] list.pop() accepting a list of integers as argument

Serhiy Storchaka storchaka at gmail.com
Thu Mar 26 08:41:53 CET 2015


On 26.03.15 05:36, Ron Adam wrote:
> This is probably the fastest way to remove N items from the end.
>
>  >>> L = list("123456789")
>  >>> L
> ['1', '2', '3', '4', '5', '6', '7', '8', '9']
>  >>> L[-3:] = []
>  >>> L
> ['1', '2', '3', '4', '5', '6']

del L[-3:]




More information about the Python-ideas mailing list