Program in Python

Program in Python
0.0 0

#1

Hi ,
Could anyone solve this python program?
It could be very easy for python programmers.

The input dict is {‘a’ :100, ‘b’ :200, ‘c’: 300, ‘d’ : 200, ‘e’ :100}
The output is {100:[‘a’,‘e’], 200:[‘b’, ‘d’] ,300:[‘c’]}

What’s the solution?

Thanks in advance,
Aparna Sen


#2

dict1={‘a’:100,‘b’:200,‘c’:300,‘d’:200,‘e’:100}

key_list=list(dict1.keys())
value_list=list(dict1.values())
value_new_list=list(set(value_list))

dic_new={}
for k in value_new_list:
** z=list()**
** for i ,x in enumerate(value_list):**
** if x==k:**
** z.append(key_list[i])**
** dic_new[k]=z**

dic_new

I am also learner check out this solution…!!!


#3

Thank you so much Digvijay.
it worked fine as I can see .Cheers!!

Let me try it using your logic.

Thanks
Aparna