issue transforming Python dictionary of one-itemed list to dictionary of floats -


i have dictionary one-itemed lists values. how can transform them dictionary of floats?

i've tried way, can't work:

dict = {a:[1.25], b:[3.35], c:[3.24]} lst in dict.values():     lst = lst[0] 

the dictionary stays same, i'd be: dict = {a: 1.25, b: 3.35, c: 3.24}

you're close!

for k in dict:     dict[k] = dict[k][0] 

also, since dict built-in class name, should avoid using variable.


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -