Write a function named first_three that accepts a list L of distinct
integers as argument. It should return the first maximum, second maximum and
third maximum in the list, in this order. You can assume that the input list
will have a size of at least three.
Returning three values from a single return statement gives back a tuple, so
first_three returns a tuple of three integers.
The list passed to the function must not be disturbed: after the call, L should
still hold exactly the elements it held before the call. Work on a copy if you
need to remove elements.
You do not have to accept input from the user or print anything to the console. You just have to write the function definition.
Example
first_three([6, 7, 1, 5, 4, 3, 2]) -> (7, 6, 5)
Implement this function:
def first_three(L):
Write the function only — the arguments are read for you and the return value is printed automatically.
Arguments arrive as one Python literal per line, in this order: L.
Input
[6, 7, 1, 5, 4, 3, 2]
Output
(7, 6, 5)