Remove elements from the list in Python

Rumman Ansari   Software Engineer   2022-10-04 00:00:00   234 Share
Subject Syllabus DetailsSubject Details
☰ Table of Contents

Table of Content:


Python provides the remove() function which is used to remove the element from the list. Consider the following example to understand this concept.

Example


list = [0,1,2,3,4]     
print("printing original list: ");    
for i in list:    
    print(i,end=" ")    
list.remove(2)    
print("\nprinting the list after the removal of first element...")    
for i in list:    
    print(i,end=" ")  

Output


printing original list: 
0 1 2 3 4 
printing the list after the removal of first element...
0 1 3 4