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

 

david.white@denison.edu cs111fall2019 > distinct
prev  |  next  |  chance

Write a function

 distinct(data) 
that returns a list containing ONLY the distinct elements in the list data. Use a dictionary and sort the list before returning it. You may assume that all of the list items are of the same type, so that L.sort() works.

distinct(['a', 'b', 'a', 'b', 'c']) → ['a', 'b', 'c']
distinct(['a', 'b', 'A', 'z', 'c']) → ['A', 'a', 'b', 'c', 'z']
distinct([0, 1, 2, 1, 4]) → [0, 1, 2, 4]

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

def distinct(data):

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

Copyright Nick Parlante 2017 - privacy