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
Post a Comment