Python List Remove

python-list-remove-1

Here, we will learn Python list remove method. In other words, we will focus how to delete a member of a list in python. Here the members of the list that will used as a parameter of remove method, will be deleted from the python list. The other remove method is Python list pop method.

 

Now, let’s do an example for this method of Python. Below, we will delete two different members of a given string list one by one. With each one, the members used with this method will be deleted  from the list.

 

elves = ["Arwen", "Legolas", "Elrond", "Galadriel"]
elves.remove("Galadriel")
print(elves)

 

['Arwen', 'Legolas', 'Elrond']

 


You can also learn the other methods of Python Lists


 

python-list-remove-1

 

The outputs of these two codes will be like below orderly.

 

elves = ["Arwen", "Legolas", "Elrond", "Galadriel"]
elves.remove("Legolas")
print(elves)
['Arwen', 'Elrond', 'Galadriel']

 

As you can see, Legolas has removed from the list with the aabove remove method.

 

Let’s show this function with also a number list.

 

numbers = [15,23,37,42,55,68]
numbers.remove(37)
print(numbers)

 

[15, 23, 42, 55, 68]

 


You can also learn how to find Lenth of a Python List


 

python-remove-a-list-item-2

 

numbers = [15,23,37,42,55,68]
numbers.remove(55)
print(numbers)

 

[15, 23, 37, 42, 68]

 

The output of this two codes will be like below orderly . As you can see below, for each code, the mentioned member of the list is deleted from the list.

 

Here, we have learned an important method for Python list remove process. This method is remove () method.  You can use this method for your different python codes that includes lists. In Python programming course, we will give different examples for different methods of python. You can practice on these examples and improve your programming experience.

 

Back to: Python Programming Course > Python Lists

Leave a Reply

Your email address will not be published. Required fields are marked *

IPCisco is the Winner of 2019 & Finalist of 2020 in “Best Certification Study Journey ” Category!

Cisco-ITBlogAwards-2019-Winner-IPCisco-k
ITBlogAwards_2020_Badge-Finalist-BestCertStudy-ipcisco

Python Programming Course

Collapse
Expand
IPCisco on Social Media!

Latest Blog Posts

metaverse-jobs-ipcisco.com
Wifi-6-vs-wifi-5-ipcisco.com
16-Reasons-To-Learn-Linux
gns3-vm-ware-installation-guide
reasons-to-have-cisco-ccna-ipcisco-1