I have a dictionary which has a list of values and I want to use only the first value of each pair before the first comma. Is that possible?
If you came across anything similar please write it down
Advertisement
Answer
The output you expect is unclear. If you want a dictionary in which you only keep the first item of the sublist, use a dictionary comprehension:
Assuming dic1
the input.
dic2 = {k:v[0][0] for k,v in dic1.items()}