Median


#1

Please help me with code ?

def median(numbers):
numbers = []
numbers = sorted(numbers)
for number in numbers:
if number > 0:
number = len(numbers(i)) / 2.0
return number

File “python”, line 7
return number
^
IndentationError: unindent does not match any outer indentation level


#2

Hi @betarunner60954

The indentation within your code is not visible in your post because the code is not formatted.

The return statement should be indented to the same degree as the current for loop header …

  return number

… but do you really need that for loop? Your code needs to make a decision based on whether numbers contains an odd or even number of items.

Make appropriate corrections, then continue to test and refine your code.


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.