How to Remove All Items From a List in Python Last Updated : 27 Nov, 2024 Summarize Comments Improve Suggest changes Share Like Article Like Report Removing all items from the list can be done by using various different methods in Python. Using clear()clear() method is the simplest and most efficient way to remove all items from a list. Python a = [1, 2, 3, 4, 5] # Remove all items using clear() a.clear() # Print the empty list print(a) Output[] Let's look into the other methods that are used to remove all items from the lists. Table of ContentUsing del(Slice[:])Reassigning to an Empty ListUsing Multiplication with Zero(* 0)Using del(Slice[:])Another way to remove all items is by using the del() keyword. This removes everything from the list in place. Python a = [1, 2, 3, 4, 5] # Remove all items using del del a[:] print(a) Output[] Reassigning to an Empty ListThis method creates a new empty list and makes the original variable point to it. This approach is efficient to clear other elements from the list. Python a = [1, 2, 3, 4, 5] # Reassign to an empty list a = [] print(a) Output[] Using Multiplication with Zero(* 0)By multiplying a list by 0 will help to modify the list in place. It will create a new list and does not modify the original list. Python a = [1, 2, 3, 4, 5] # Using (*= 0) to clear the list a *= 0 print(a) Output[] Comment More infoAdvertise with us Next Article How to Remove All Items From a List in Python P pragya22r4 Follow Improve Article Tags : Python Python Programs python-list Python list-programs Practice Tags : pythonpython-list Similar Reads Remove an Element from a List by Index in Python We are given a list and an index value. We have to remove an element from a list that is present at that index value in a list in Python. In this article, we will see how we can remove an element from a list by using the index value in Python. Example: Input: [1, 2, 3, 4, 5], index = 2 Output: [1, 2 3 min read Remove Dictionary from List If Key is Equal to Value in Python Removing dictionaries from a list based on a specific condition is a common task in Python, especially when working with data in list-of-dictionaries format. In this article, we will see various methods to Remove Dictionary from List If the Key is Equal to the Value in Python.Using filter()filter() 2 min read Remove Items from a List While Iterating - Python When we need to remove items from a list while iterating, we have several options. If we need to remove specific values, using a for loop with remove() can work, but itâs important to avoid skipping items by iterating over a copy. A while loop offers more control and filter() is a good approach for 2 min read Python - Remove elements at Indices in List In Python, lists store items in a specific order and each item has an index. Removing elements by index means creating a new list that excludes items at certain positions. This helps in keeping only the needed elements while discarding others based on their index. For example:Input : li= [5, 6, 3, 7 2 min read Python | Remove given element from the list Given a list, write a Python program to remove the given element (list may have duplicates) from the given list. There are multiple ways we can do this task in Python. Let's see some of the Pythonic ways to do this task. Example: Input: [1, 8, 4, 9, 2] Output: [1, 8, 4, 2] Explanation: The Element 9 7 min read Like