Python Hapus duplikat dari daftar
mylist = ["a", "b", "b", "c", "a"]
mylist = sorted(set(mylist))
print(mylist)
mylist = ["a", "b", "b", "c", "a"]
mylist = sorted(set(mylist))
print(mylist)
mylist = ["a", "b", "a", "c", "c"]
mylist = list(dict.fromkeys(mylist))
print(mylist)
def remove_dupiclates(list_):
new_list = []
for a in list_:
if a not in new_list:
new_list.append(a)
return new_list
# ----- Create a list with no repeating elements ------ #
mylist = [67, 7, 89, 7, 2, 7]
newlist = []
for i in mylist:
if i not in newlist:
newlist.append(i)
ar = [1,2,1,2,1,3,2]
ar = list(sorted(set(ar)))
print(ar)
ArrayList<Object> withDuplicateValues;
HashSet<Object> withUniqueValue = new HashSet<>(withDuplicateValues);
withDuplicateValues.clear();
withDuplicateValues.addAll(withUniqueValue);