HTML tutorial
CSS3 tutorial
Bootstrap tutorial
JavaScript tutorial
JQuery tutorial
AngularJS tutorial
React tutorial
NodeJS tutorial
PHP tutorial
Python tutorial
Python3 tutorial
Django tutorial
Linux tutorial
Docker tutorial
Ruby tutorial
Java tutorial
C tutorial
C ++ tutorial
Perl tutorial
JSP tutorial
Lua tutorial
Scala tutorial
Go tutorial
ASP.NET tutorial
C # tutorial
There are several methods to remove items from a list:
The remove()
method removes the specified item:
thislist = ["apple", "banana", "cherry"]
thislist.remove("banana")
print(thislist)
The pop()
method removes the specified
index, (or the last item if index is not specified):
thislist = ["apple", "banana", "cherry"]
thislist.pop()
print(thislist)
The del
keyword removes the specified
index:
thislist = ["apple", "banana", "cherry"]
del
thislist[0]
print(thislist)
The del
keyword can also delete the list
completely:
thislist = ["apple", "banana", "cherry"]
del
thislist
The clear()
method empties the list:
thislist = ["apple", "banana", "cherry"]
thislist.clear()
print(thislist)