I have two lists:
header = ["Name", "Age"]
detail = ["Joe", 22, "Dave", 43, "Herb", 32]
And would like to create a list of dictonaries like this:
[{"Name": "Joe", "Age": 22}, {"Name": "Dave", "Age": 32}, {"Name": "Herb", "Age": 32}]
This method zip gets me partially there, but only adds the first set of values to the dictionary:
>>> dict(zip(header, detail))
{'Age': 22, 'Name': 'Joe'}
How can I output as one dictionary for all values in the detail
list? I found this answer, but this depends on detail
containing nested lists.