1mylist = ["a", "b", "b", "c", "a"]
2mylist = sorted(set(mylist))
3print(mylist)
1
2 mylist = ["a", "b", "a", "c", "c"]
3mylist = list(dict.fromkeys(mylist))
4
5 print(mylist)
1# HOW TO REMOVE DUPLICATES FROM A LIST:
2# 1) CREATE A LIST
3my_list = [1, 2, 3, 4, 5, 5, 5, 1]
4# 2) CONVERT IT TO A SET AND THEN BACK INTO A LIST
5my_list = list(set(my_list))
6# 3) DONE!
7print(my_list) #WILL PRINT: [1, 2, 3, 4, 5]
1# remove duplicate from given_list using list comprehension
2res = []
3[res.append(x) for x in given_list if x not in res]