Dict(zip) question

for this exercise

https://app.dataquest.io/m/1011/python-fundamentals-practice-problems/7/converting-a-csv-to-a-dictionary

How would you write the dict(zip(name, email)) code to create the dictionary here?
It was mentioned page 5/13 and looked like an easy alternative, I cant get it to work here though
Thanks

1 Like

using dict() & zip() function here will take a lot of code. The best method that i used was dictionary comprehension

name_to_email={data[0]:data[-1] for data in list(reader(open('users.csv')))[1:]}

Using the dict() & zip() way, you’ll have to extract the columns first, then zip them, then create a dictionary, that will be a long way to go.

Okay, thank you for clarifying this

1 Like