Write a function, using set
objects, to remove duplicates from an ordered list
. For example,
>>> remove_dupes([1,1,2,3,4,4,4,5,7,8,8,9])
[1, 2, 3, 4, 5, 7, 8, 9]
This function can be used to remove duplicates from an ordered list.
>>> def remove_dupes(l):
... return sorted(set(l))
...
>>> remove_dupes([1,1,2,3,4,4,4,5,7,8,8,9])
[1, 2, 3, 4, 5, 7, 8, 9]
Note that although sets don't have an order, they are iterable and can be passed to the sorted
builtin method (which returns a list
.)