Answers for "remove duplicates using set python on unsorted dictionary"

0

python set remove duplicate elements

new_menu = ['Hawaiian', 'Margherita', 'Mushroom', 'Prosciutto', 'Meat Feast', 'Hawaiian', 'Bacon', 'Black Olive Special', 'Sausage', 'Sausage']

final_new_menu = list(set(new_menu))

print(final_new_men)

#output = ['Hawaiian', 'Margherita', 'Mushroom', 'Prosciutto', 'Meat Feast', 'Bacon', 'Black Olive Special', 'Sausage']
Posted by: Guest on May-20-2021
-1

python remove duplicates from list of dict

# set the dict to a tuple for hashability, then use {} for set literal and retrn each item to dict. 
[dict(t) for t in {tuple(d.items()) for d in l}]
# using two maps()
list(map(lambda t: dict(t), set(list(map(lambda d: tuple(d.items()), l)))))
Posted by: Guest on March-27-2021

Code answers related to "remove duplicates using set python on unsorted dictionary"

Python Answers by Framework

Browse Popular Code Answers by Language