Switch minimum and maximum

Write the modifier function min_x_max() that takes an homogeneous list, and modifies it by switching its maximum element with its minimum element. Suppose that the list is not empty and does not have repeated elements.

Save the function into the file named switch.py. The function must pass the following doctest:

>>> a = [8, -88, 2, -4, 25, 0]
>>> min_x_max(a)
>>> a
[8, 25, 2, -4, -88, 0]

>>> b = [-34.0]
>>> min_x_max(b)
>>> b
[-34.0]

>>> c = ['pear', 'apple', 'melon', 'watermelon', 'orange']
>>> min_x_max(c)
>>> c
['pear', 'watermelon', 'melon', 'apple', 'orange']

Note

More tests are provided in the test-switch.txt.

Solution

A solution of these functions is provided in the switch.py