This is my code, I am unsure as to why it doesn't work.
def median(input_list): for i in input_list: if len(input_list) % 2 == 0: sorted(input_list) middle1 = x / 2.0 middle2 = middle1 - 1 average_even = (middle1 + middle2) / (2.0) return average_even break else len(input_list) % 2 != 0: sorted(input_list) middle = x / 2.0 average_odd = middle return average_odd break
I get the error:
Oops, try again. Your code did not run to end. Check the console window for errors!
And this is printed in the console:
File "python", line 11
else len(input_list) % 2 != 0:
SyntaxError: invalid syntax