In Python, a dictionary is a collection of keys and their associated values. The keys of a Python dictionary
correspond to the words in a paper dictionary; the values of a Python dictionary correspond
to the meanings of these words.
Here is an example of a Python program that uses a dictionary to store patient names and IDs:
idlist = {"Smith,Mary":"P12345", "Doe,John":"P12346", "Jones,Charlie":"P12347",
"Public,John":"P12348", "Dobbs,Cindy":"P12349"}
sortedkeys = idlist.keys()
sortedkeys.sort()
for name in sortedkeys:
patientid = idlist[name]
print name, "has patient ID", patientid
For more information on dictionaries, see the following sections: