diff --git a/1.28/remove_duplicates.py b/1.28/remove_duplicates.py new file mode 100644 index 0000000..ed2a86c --- /dev/null +++ b/1.28/remove_duplicates.py @@ -0,0 +1,32 @@ +""" +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()