Dictionary

A dictionary is a data structure that can store values by their keys.

Input:

# source_code/appendix_c_python/example08_dictionary.py
dictionary_names_heights = {}
dictionary_names_heights['Adam'] = 180.
dictionary_names_heights['Benjamin'] = 187
dictionary_names_heights['Eva'] = 169
print 'The height of Eva is', dictionary_names_heights['Eva'], 'cm.'

Output:

$ python example08_dictionary.py 
The height of Eva is 169 cm.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset