Rows Into Records

Python for AIMedium+10 XP+10

Rows Into Records

You've split a CSV file into a header and some rows. Every row is a list of text values in the same order as the header.

Write to_records(header, rows). It returns a list of dictionaries, one per row, where each key comes from the header and each value from that row.

Keep the rows in order. No rows gives back an empty list.

Examples

header = ["name", "city"]
rows = [["Ada", "Oslo"]]
returns [{'name': 'Ada', 'city': 'Oslo'}]
header = ["name", "age"]
rows = [["Ben", "41"], ["Cleo", "29"]]
returns [{'name': 'Ben', 'age': '41'}, {'name': 'Cleo', 'age': '29'}]

Hints

Solve it to unlock the solution

Once your code passes every test, a reference solution shows up here so you can compare it with yours.

solution.py
CtrlEnterto run