Newer
Older
bth_py_exercises / 1.28 / remove_duplicates.py
@Pascal Syma Pascal Syma on 2 Sep 2021 609 bytes Completed 1.28
"""
Exercise 1.28  - Remove Duplicates II
"""


#  Copyright (c) 2021. Pascal Syma. All rights reserved.

def remove_duplicates(my_list):
    """
    Remove duplicates from a list, modifies the original list.
    :param my_list: List
    """
    temp_list = my_list.copy()
    my_list.clear()

    for i in temp_list:
        if i not in my_list:
            my_list.append(i)


def main():
    """
    Main function
    """
    my_list = [12, 24, 35, 24, 88, 120, 155, 88, 120, 155]
    print(f'{my_list = }')
    remove_duplicates(my_list)
    print(f'{my_list = }')


if __name__ == '__main__':
    main()