Python‎ > ‎keywords‎ > ‎

del


Definition
The keyword delete the object.

Syntax
del

Parameters
N/A

Examples
del(dict)

The function deleted the dictionary.
dict1={'Adil':33, 'John':55, 'Eric':45, 'Robert':19}
del(dict1)
>>> 
>>> 

del a[b]
The method perform same function as operator.delitem(a, b).
 >>> a=[1,3,5,7,9]
>>> del a[2]
>>> a
[1, 3, 7, 9]

del(set)
The function delete the set but the set.clear() only delete the item while the set remain in the Python memory.
 >>> set1={3,45,344,66}
>>> del(set1)
>>> set1
Traceback (most recent call last):
File "<pyshell#3>", line 1, in <module>
set1
NameError: name 'set1' is not defined
>>>

Comments