Dictionaries in Python

Features of a Dictionary
A dictionary is a collection of objects. It contains the following features:
- It is unordered
- It is changeable
- It is indexed
- Uses key value pairs
1) Create a Dictionary
Dictionaries are created with an empty pair of curly brackets.
2) Accessing items in a Dictionary
You can access items using the key or use the get() method or use the key inside of square brackets.
3) Change a value in a Dictionary
Use the key to change a value in the dictionary.
4) Loop through a Dictionary and access the keys in the Dictionary
Use a for loop to iterate through the keys of a dictionary.
5) Loop through a Dictionary and access the values in the Dictionary
To loop through the values of a Dictionary use a for loop and put the looping value inside of square brackets:
6) Loop through a Dictionary and access the values and keys in the Dictionary
To loop through the values of a Dictionary use a for loop with 2 looping values:
7) Check if a value exists in a Dictionary
Use the “in” keyword to check if a value exists in a Dictionary.
8) Get the length of a Dictionary
Use the len() method to get the size/length of a Dictionary.
9) Remove an item from a Dictionary using a key
Use the pop method to remove an item from a Dictionary.
10) Clear all items from a Dictionary.
Use the clear() method to clear all items from a dictionary