Dict(zip) question

for this exercise


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

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