Duplicate values? Who needs them!

Given a list of values with duplicates, return a list holding the same values in the same order with all duplicates removed.

duplicates = ['a', 'a', 'x', 'x', 'x', 'g', 't', 't'] remove_dups(duplicates) # ['a', 'x', 'g', 't'] more_duplicates = [3, 3, 1, 7, 7, 7] remove_dups(more_duplicates) # [3, 1, 7]

This is a great problem because there are many different ways to solve it. Questions with multiple solutions are an opportunity to discuss with the interviewer.

Remember: the ability to communicate is essential!

Clarifying Questions:

  • Are there constraints on time or space efficiency?
    • No! Any solution will do.
  • Is it okay to alter the input list?
    • You can alter the list or return a new list.



Write a function remove_duplicates() which has one parameter: dupe_list.

remove_duplicates() should return a list containing unique values in the same order as in dupe_list.

Sign up to start coding

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?