del Delete binding
Last updated: 2026-09-22
del Delete binding
del deletes a name, attribute, or container item (releasing the reference).
| Category | Keywords & Statements |
|---|---|
| Kind | Keyword / Statement |
| Python Version | all |
📝 Syntax
del target [, target]*
▶ Example
Edit the code, press Run, and see the result in the output panel:
Output:
[2, 3]
💡 Related Cases
More case studies coming soon — check back later.
❓ FAQ
QWhat is the difference between `del x` and `x = None`?
A`del x` removes the name binding; accessing `x` afterward raises `NameError`. `x = None` just makes `x` point to `None`; the name still exists. `del lst[i]` removes a list element, changing the list's length.
QCan `del` delete a list slice?
AYes. `del lst[1:3]` removes a slice of elements; `del lst[:]` empties the whole list but keeps the same list object (unlike assigning a new list).
QDoes `del` release memory immediately?
ANot necessarily. `del` only releases one reference; the object is reclaimed only when its reference count reaches zero (and there is no reference cycle). The exact timing is decided by the interpreter.