3. List Remove Duplicates

A function that removes duplicates from a list. For example, given the list [1, 2, 2, 3, 4, 4, 5], the function should return [1, 2, 3, 4, 5].

image

Another way to remove duplicate list

def remove_duplicate_list(duplicate_list = []):
    for i in range(len(duplicate_list) - 1, 0, -1):
        for j in range(0, i):
            if duplicate_list[j] == duplicate_list[i]:
                duplicate_list.pop(i)
                break
    return duplicate_list

Another way:

def remove_duplicates(l):
    uniques = []
    for item in l:
        if item not in uniques:
            uniques.append(item)
    return uniques