L3-2 Dictionary Helpful Methods
Here are some common functions that will come in handy when we need to update or access content in a dictionary
| Function | Description |
|---|---|
[] | Returns the value of the keykeyKeyError |
get(<key>) | Returns the value of the keykeyNone |
items() | Returns a list containing a tuple for each key value pair. |
keys() | Returns a list containing the dictionary's keys. |
values() | Returns a list containing the dictionary's values. |
pop(<key>) | Removes the item with the key |
clear() | Removes all items from the dictionary. |
in | Check if the given key exist in the dictionary |
Check if Key Exists in Dictionary
Similar to lists, we can use the
in