Errors:

With even total numbers in list: Oops, try again. median([1]) returned 3.0 instead of 1

With odd total numbers in list: Oops, try again. median([1]) returned 3 instead of 1

I have run into a number of script errors using the codecademy script, so I've taken to writing the code with vim, and then executing it in python3.5 on another computer for much nicer error handling. The following code, regardless of whether I have a list of even numbers out of numerical order or a list of odd numbers outputs the correct answer, but the codecademy script keeps giving me the above error.

Currently, I'm trying to figure out how to format it so the script will take it and I can move on. It should be noted that the output in the codecademy script and interpreter is also correct.

```
def median(sequence):
sort = (sorted(x))
num = int(len(sort)/2)
if len(sort) % 2 == 0:
med_even = (sort[num] + (sort[num-1])) / 2.0
return med_even
else:
if (len(sort)) % 2 != 0:
med_odd = (sort[num])
return med_odd
x = [1, 7, 4, 2]
print(sorted(x))
print(median(x))
```

Interpreter output in codecademy:

[1, 2, 4, 7]

3.0

None

Remote computer output with a different string of numbers:

[2, 6, 8, 10]

7.0

Press ENTER or type command to continue

Odd total numbers on codecademy:

[1, 2, 3, 4, 7]

3

None

Odd total numbers on remote computer with different list:

[2, 6, 8, 10, 23]

8

Press ENTER or type command to continue