Bummer! This is just a preview. You need to be signed in with an account to view the entire instruction.
Well done!
You have completed (UPI) Chapter 12: Mastering Python Dictionaries!
Instruction
Dictionary Creation
Two methods exist for creating an empty dictionary:
-
Using curly braces {}.
- Example:
dict_1 = {}
.
- Example:
-
Using the
dict()
function.
- Example:
dict_2 = dict()
.
- Example:
A dictionary object can also be created with initial key-value pairs enclosed in curly braces.
- Example:
my_dict = {"pizza": 2, "pasta": 3, "drink": 4}
creates a dictionary objectmy_dict
. A key...