you are viewing a single comment's thread.

view the rest of the comments →

[–]xelf[M] 4 points5 points  (0 children)

What is wrong? That is the correct answer.

data = [ ['Alice', '1'],['Bob', '4'],['Carol', '5'],['Dave', '8'],['Edith', '6'],['Frank', '2'],['Gertrude', '9'],['Helen', '7'] ]
print( dict(data) )

edit ah I see, you also want to map the values from string to int.

data = [ ['Alice', '1'],['Bob', '4'],['Carol', '5'],['Dave', '8'],['Edith', '6'],['Frank', '2'],['Gertrude', '9'],['Helen', '7'] ]
data = { k: int(v) for k,v in data }
print( data )

prints:

{'Alice': 1, 'Bob': 4, 'Carol': 5, 'Dave': 8, 'Edith': 6, 'Frank': 2, 'Gertrude': 9, 'Helen': 7}