Median(numbers) returns unsupported operand type(s) for /: 'list' and 'int'


#1


https://www.codecademy.com/courses/python-intermediate-en-rCQKw/2/5?curriculum_id=4f89dab3d788890003000096#

Oops, try again. median([1]) resulted in an error: unsupported operand type(s) for /: 'list' and 'int'


def median(numbers):
    n=sorted(numbers)
    median=0
    if len(n)==1:
        median=n[0]
    if len(n) > 2 and len(n)%2==0:
        median=(n[len(n/2)-1]+n[len(n/2)])/2.0
    else:
        median=n[len(n/2)]
    return median


#2

Read the error message carefully and see if you can spot something corresponding in your code.

>>> [] / 5
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for /: 'list' and 'int'