python list remove duplicates set code example

Example 1: python remove duplicates from list

mylist = ["a", "b", "b", "c", "a"]
mylist = sorted(set(mylist))
print(mylist)

Example 2: 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']