


def median(list):
    sorted_list = sorted(list)
    if len(sorted_list) % 2 != 0:

        index = len(sorted_list ) //2
        return sorted_list[index]
    elif len(sorted_list) % 2 == 0:

        index_1 = len(sorted_list ) /2 - 1
        index_2 = len(sorted_list ) /2
        mean = (sorted_list[index_1] + sorted_list[index_2] ) /2.0
        return mean

print (median([2, 5, 8]))