Last updated on February 1, 2023
To remove all the items from the list you can use the clear() method in python. It doesn’t accept any parameter because it removes all the items.
Let’s create a list of devices and store them into a variable.
devices = ["laptop", "phone", "watch"]
In this variable we have stored the list that has few items. To remove all the items we can attach a clear() method with devices variable which will remove the items.
devices.clear()
Now to check the items inside the list we can print it.
print(devices)
# Output: []
In the response we got an empty list which means clear() method successfully removed all the items.