November 2017
Beginner to intermediate
204 pages
5h 23m
English
A dictionary, like an array, is a collection of items; however, the items in a dictionary are referenced by strings called keys, rather than their order in a list. Another way to think of a dictionary is as a collection of key-value pairs, where the keys are used to retrieve the values.
To create a dictionary, use the following syntax where <key1>, <key2> are strings and value1, value2 are any values:
{<key1>:<value1>,<key2>:<value2>,<key3>:<value3>}
The following line will create a dictionary called d with two key-value pairs:
>> d = {"some_number": 1, "sup?": "yo!"}>> print(d)
You can access a specific value of a dictionary using the following ...
Read now
Unlock full access