Python ProgrammingPython Programming

How to delete or remove a specific list item in python?

You can use remove() method, to delete or remove specified item from a list. The pop() method removes the specified index item if passed or the last item of list.
testList = ["Canada", "Japan", "London", "Germany"]
print(testList)
 
testList.remove("Japan")  # Japan removed
print(testList)
 
testList.pop(1)  # London removed
print(testList)
 
testList.pop()  # Last item removed
print(testList)
Output
['Canada', 'Japan', 'London', 'Germany']
['Canada', 'London', 'Germany']
['Canada', 'Germany']
['Canada']