id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

remove_duplicates


Write a function remove_duplicates that takes as a parameter a sorted list of strings and that eliminates any duplicates from the list. For example, suppose that a variable called list contains the following values: ["be", "be", "is", "not", "or", "question", "that", "the", "to", "to"] After calling remove_duplicates(list) the list should store the following values: ["be", "is", "not", "or", "question", "that", "the", "to"] Because the values will be sorted, all of the duplicates will be grouped together.


remove_duplicates(['be', 'be', 'is', 'not', 'or', 'question', 'that', 'the', 'to', 'to']) → ['be', 'is', 'not', 'or', 'question', 'that', 'the', 'to']
remove_duplicates(['a', 'a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'c', 'c', 'c', 'd', 'e', 'e', 'e', 'e']) → ['a', 'b', 'c', 'd', 'e']
remove_duplicates(['be', 'is', 'not', 'or', 'question', 'that', 'the', 'to']) → ['be', 'is', 'not', 'or', 'question', 'that', 'the', 'to']

...Save, Compile, Run (ctrl-enter)

def remove_duplicates(lst):

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Python Help

Difficulty: 290 Post-solution available

Copyright Nick Parlante 2017 - privacy