0

remove duplicate values in python dictionaries

...

8th Nov 2019, 10:37 AM
D Dheeraj
D Dheeraj - avatar
5 Answers
+ 2
Dheeraj.D, removing anything is different to removing duplicates. You can erase single items with del. In relation to my example above, let's say, the name of the dict is 'd', for example: del d['dog'] If you want to empty the whole dict, use: d.clear()
8th Nov 2019, 6:04 PM
HonFu
HonFu - avatar
+ 6
Can you show us your code / try or what you have done so far this task?
8th Nov 2019, 11:38 AM
Lothar
Lothar - avatar
+ 4
You can only have duplicate values in a dict, if the same value is stored under different keys. {'cat': 'chat', 'dog': 'chat'} On which basis do you decide which key to keep?
8th Nov 2019, 12:59 PM
HonFu
HonFu - avatar
+ 2
Thanks bro
8th Nov 2019, 6:10 PM
D Dheeraj
D Dheeraj - avatar
0
HonFu remove anything
8th Nov 2019, 4:06 PM
D Dheeraj
D Dheeraj - avatar