Middle value

Write code · Basic · §6.1 Putting things in order

Complete the function solution, which returns the value in the middle when the integer list nums is sorted in ascending order.

If there is an even number of elements, return the smaller of the two middle values. Do not change the original list nums.

Function

solution(nums)

Constraints

Examples

numsresult
[5, 1, 4]4
[8, 2, 6, 4]4

Starter code

def solution(nums):
    answer = 0
    return answer

Solve this problem in your browser

Python runs in your browser and checks your answer right away. Hints and the answer are on the problem page.