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?
It doesn't sound like you're working with a list of lists, so I'll keep this short. You want to use pop since it will remove elements not elements that are lists, you should use del for that. To call the last element in python it's "-1"
>>> test = ['item1', 'item2']
>>> test.pop(-1)
'item2'
>>> test
['item1']