Q8.215 Points Write a non-recursive method to return a output list that remove duplicate elements in the input list. For example, if the list is 10, 33, 28, 33, 50, 10, 20, 33, 15, 20, the output array should contain only 10, 33, 28, 50, 20, 15. Notice that the order is matter. In other words, the output array contains all elements from the list, except all duplicates elements are removed. You should not change the list. The return value is the output array. O(N^2).

Respuesta :

Answer:

def remove_duplicates(duplicate_list):

   new_list = []

   for number in duplicate_list:

       if number not in new_list:

           new_list.append(number)

   return new_list

Explanation:

- Initialize a new list to hold the values that are not duplicates

- Loop through duplicate_list, check if the number is not in the new_list, put that number in the new_list using append method

- At the end of the loop, return the new_list

ACCESS MORE