15/15 median


#1

def median(a_list):

sorted_list = sorted(a_list)
list_length = len(sorted_list)

if list_length == 1:
    return sorted_list[0]
elif list_length % 2 != 0:
    return sorted_list[(list_length // 2)]
else:
    return ((sorted_list[(list_length /2) - 1] + sorted_list[list_length / 2]) / 2.0)

That worked just right; now, to the exam! cheers!


#2

PLEASE read THIS. Thankyou


#3

thanx for the advice!


#4

Btw @eigermann you can invite people if your anwser dosent get anwsered for long. I dont know python so not me :frowning: