How do I remove an element from a list by index in Python?
I found the list.remove method, but say I want to remove the last element, how do I do this?
list.remove
pop is also useful to remove and keep an item from a list. Where del actually trashes the item.
del
>>> x = [1, 2, 3, 4] >>> p = x.pop(1) >>> p 2