Today's challenge is rather straightforward.
Instructions
Return the two distinct highest values in a list. If there're less than 2 unique values, return as many of them, as possible.
The result should also be ordered from highest to lowest.
Examples:
[4, 10, 10, 9] => [10, 9]
[1, 1, 1] => [1] [] => []
Approach
Obtain the unique values in the list using set then sort the list in reverse order and slice to obtain the first two elements.
Solution
def two_highest(arg1):
return sorted(set(arg1),reverse=True)[0:2]
You are all set.
Top comments (0)