Python del Keyword
To delete an object. The del keyword deletes an object, usually something in a list.
Example
Python
Copy Code
planets = ["Mercury", "Venus", "Earth", "Mars", "Jupiter", "Saturn", "Uranus", "Neptune", "Pluto"] del planets[8] print(planets)
Output
['Mercury', 'Venus', 'Earth', 'Mars', 'Jupiter', 'Saturn', 'Uranus', 'Neptune']
Notes
Because everything is an object in Python, you can delete class definitions, variables, even functions. This is not usually done!