Solution 1

def remove_duplicates_in_order(a_list):
    new_list = []
    for element in a_list:
        if element not in new_list:
            new_list.append(element)

    return new_list

Remove duplicates in Order

Write a function remove_duplicates_in_order that receives a list and returns a new list with the duplicates elements removed.

Important! The elements should be in order (sets are not probably a good idea). Example:

remove_duplicates_in_order([2, 1, 1, 3, 4])  # [2, 1, 3, 4]

Test Cases

test remove duplicates in order with empty list - Run Test

def test_remove_duplicates_in_order_with_empty_list():
    assert remove_duplicates_in_order([]) == []

test remove duplicates in order - Run Test

def test_remove_duplicates_in_order():
    assert remove_duplicates_in_order([2, 1, 1, 3, 4]) == [2, 1, 3, 4]
def remove_duplicates_in_order(a_list): pass