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
Use the del statement:
del listName[-N]
For example, if you want to remove the last 3 items, your code should be:
del listName[-3:]
For example, if you want to remove the last 8 items, your code should be:
del listName[-8:]