Creating
a Dictionary
A Dictionary
is a data structure. The data is stored using a Key (ie. name)
and a Value (ie. the data). Data can be retrieved from the
dictionary with the Key.
The Key and Value pair are separated by a colon (:).
The dictionary is enclosed with brackets and the data (Key : Value
pairs) is separated by commas.
A dictionary can hold numbers,
objects, strings, lists, etc
Example:
# create a
dictionary of phone numbers
phonebook = { "Fred" : "555-1111",
"Alison" : "555-2222",
"George" : "555-3333",
"Rachel" : "555-4444" }