| 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 |
|
Updated on Mon Sep 21 15:53:24 2020.
If you see any errors or have comments, please let us know.
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License