Google News
logo
Python Program to Empty a list
You can empty a list in Python by assigning an empty list to it or by using the `clear()` method. Here are two examples :

Example 1: Using assignment operator :

Program :
my_list = [1, 2, 3, 4, 5]
my_list = []
print(my_list)  # Output: []
Output :
[]

Example 2: Using clear() method :

Program :
my_list = [1, 2, 3, 4, 5]
my_list.clear()
print(my_list)  # Output: []
Output :
[]