So heres my code for the median function:

def median (List):

--lent = len(List)

--List = sorted(List)

--if lent%2 == 0:

----return ( ( List[(lent/2)-1] + List[(lent/2)] ) / 2 ) #since index start counting from 0, I substract 1 to the len/2 eg: in [1,2,3,4] I would get (4/2)-1 to get index[1], so I add numbers 2 and 3, and then divide by two to get the average.

--else:

----return ( List[(lent-1)/2] ) #since list has odd amount of numbers y substract 1 off the lenght and divide to locate the middle number

when I run, console says: " median([4, 5, 5, 4]) returned 4 instead of 4.5"

i really cant find any mistake in my code, I commented the whys of each operation. Any help would be appreciated.