diff --git a/native-datatypes.html b/native-datatypes.html index 502a16a..88865f7 100644 --- a/native-datatypes.html +++ b/native-datatypes.html @@ -446,12 +446,12 @@ IndexError: pop from empty list
⁂
One of Python’s most important datatypes is the dictionary, which defines one-to-one relationships between keys and values. +
One of Python’s most important datatypes is the dictionary. A dictionary is an unordered set of key-value pairs. When you add a key to a dictionary, you must also add a value for that key. (You can always change the value later.) Python dictionaries are optimized for retrieving the value when you know the key, but not the other way around.
☞A dictionary in Python is like a hash in Perl 5. In Perl 5, variables that store hashes always start with a
%character. In Python, variables can be named anything, and Python keeps track of the datatype internally.
Creating a dictionary is easy. The syntax is similar to sets, but instead of values, you have key-value pairs. Once you have a dictionary, you can look up values by their key. +
Creating a dictionary is easy. The syntax is similar to sets [FIXME link fails because section is not written yet], but instead of values, you have key-value pairs. Once you have a dictionary, you can look up values by their key.
>>> a_dict = {'server':'db.diveintopython3.org', 'database':'mysql'} ①
>>> a_dict