Error: Oops, try again. median([4, 5, 5, 4]) returned 4 instead of 4.5
Whether I change the modulo condition to 0 or 1, I still receive 4.5 for the above error. I think that means that that elif statement is never executing? I'm lost at this point, especially since this runs fine in IDLE on my laptop.
def median(lst): srt=sorted(lst) #sort list length=len(srt)-1 if length==0: #check for single entry list return lst elif length%2==0: #check if list is an odd number of entries return srt[int(length/2)+1] #return middle number else: lower=int(length/2) #define index for number below middle upper=int(length/2)+1 #define index for number above middle return (srt[lower]+srt[upper])/2 #average above indexed numbers