"Oops, try again. median([6, 8, 12, 2, 23]) returned 6 instead of 8"
I'm expecting my code to append the middle item of my numbers input into my med list. Which means I would need (len(list) - 1) % 2 in order to get the middle item number for an odd number of items. However, my code appears to be returning item instead of item in an item list with a length of 5. Not really understanding why this is happening. I would appreciate your help.
def median(numbers): med =  srt = sorted(numbers) if len(srt) % 2 == 0: mid1 = (len(srt) % 2) + 1 mid2 = len(srt) % 2 medi = (numbers[mid1] + numbers[mid2]) / 2.0 med.append(medi) else: med.append(numbers[(len(srt) - 1) % 2]) for item in med: return item