Name

del

Examples
a = [1,2,3]
print(a) # Prints: [1,2,3]
del a[0]   # Delete the list member at index 0. 
print(a) # Prints: [2, 3]
del a      # Delete the variable 'a'

b = {'a': 1, 'b': 2, 'c': 3}
print('a' in b) # Prints 'True'

del b['a']
print('a' in b) # Prints 'False'
Description Remove an item from a list given its index, or a key/value pair from a dictionary. The del keyword can also delete an entire variable.
Syntax
del a
Parameters
alist or dictionary to delete from, or variable to delete
iindex of list member or key of key/value pair to delete

Updated on Tue Feb 27 14:07:12 2024.

If you see any errors or have comments, please let us know.