A dictionary provides a convenient way to map one set of values to another. For example, this dictionary maps doctor names to their corresponding ID codes:
doctortable = { 'Smith': '123', 'Doe': '908', 'Jones': '087', 'Thomas': '416', 'Adams': '850', }
To access this table, you can use the following code:
if doctor in doctortable: doctorid = doctortable[doctor] else: # use '000' to indicate an unknown doctor doctorid = '000'
If you need to add another doctor to this table, all you need to do is add another key-value pair to the dictionary.