
- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
Delete List Elements in Python
To remove a list element, you can use either the del statement if you know exactly which element(s) you are deleting or the remove() method if you do not know.
Example
#!/usr/bin/python list1 = ['physics', 'chemistry', 1997, 2000]; print list1 del list1[2]; print "After deleting value at index 2 : " print list1
Output
When the above code is executed, it produces the following result −
['physics', 'chemistry', 1997, 2000] After deleting value at index 2 : ['physics', 'chemistry', 2000]
Note − remove() method is discussed in subsequent section.
- Related Articles
- Delete elements in C++ STL list
- Delete Tuple Elements in Python
- Delete Dictionary Elements in Python
- Delete elements in range in Python
- Python Program to Append, Delete and Display Elements of a List Using Classes
- Delete Node in a Linked List in Python
- Delete elements with frequency atmost K in Python
- Python – Adjacent elements in List
- How to delete all elements from linked list for listview in Android?
- List frequency of elements in Python
- Python – List Elements Grouping in Matrix
- Python – Restrict Elements Frequency in List
- Python – Combine list with other list elements
- Find missing elements in List in Python
- Consecutive elements pairing in list in Python

Advertisements