Python Advanced #16 - Developing Dictionaries from Lists

In this post, a dictionary is created from two lists and from four lists.

For the first example, the gage datums on the White River for the gages of Newport, Georgetown, and Batesville are in one list while the gage names are in another list.  A blank dictionary named, "datums", is created.  The list containing the gage names is titled "white_r_gages".  The list containing the datums is titled, "white_r_dat".

The Python code for creating a dictionary from these two lists is shown below.



The results of running this code are shown below.



In the next example, the gage names and datums for the Black River gages of Poplar Bluff and Black Rock are included in lists named "black_r_gages" and "black_r_dat".  The coding to create a single dictionary of White River and Black River gage names and datums is shown below.



The results of running this code are shown below.


Comments