Hey guys having a little trouble with my program here. I figured that it has something to do with my if and else statements, but I can't figure out how to correct it:
def median(num): sorts = sorted(num) x = len(num) location = int(x/2) if x % 2 == 0: mid = (sorts[x] + sorts[x - 1])/(2.0) return mid else: mid = (sorts[x]) return mid
I tried making this change, but it still came up with the same problem:
if x % 2 == 0 and len(sorts) > 1:
Any help would much be appreciated. Thanks in advance!