mylist = ["a", "b", "a", "c", "c"] mylist = list(dict.fromkeys(mylist)) print(mylist)
# ----- 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)
def my_function(x): return list(dict.fromkeys(x)) mylist = my_function(["a", "b", "a", "c", "c"]) print(mylist)