def median(sequence):
sort = sorted(sequence)
print(sort)
if len(sequence)%2 ==0:
print ((sort[int(len(sequence)/2-1)]+sort[int(len(sequence)/2)])/2)
elif len(sequence)==1:
return sort[0]
else:
return sort[int(len(sequence)/2)+1]
median([4,5,5,4])
This is part of a codecademy course. I am just a beginner in python. In codecademy, my code returned 4 instead of 4.5 However, when I input this code into pyscripter, it returned 4.5 which is the correct answer.
Is there any issues within my program, or is it just an issue of the compiler?