Python del Keyword
Definition and Usage
The del
keyword is used to delete objects.
In Python everything is an object, so the del
keyword can also be used to delete variables, lists, or parts of a list etc.
More Examples
Example
Delete the first item in a list:
x =
["apple", "banana", "cherry"]
del x[0]
print(x)
Try it Yourself »