<PLEASE USE THE FOLLOWING TEMPLATE TO HELP YOU CREATE A GREAT POST!>
<Below this line, add a link to the EXACT exercise that you are stuck at.>
https://www.codecademy.com/courses/python-intermediate-en-rCQKw/2/5?curriculum_id=4f89dab3d788890003000096#
<In what way does your code behave incorrectly? Include ALL error messages.>
Error: (with [1] supplied)
Oops, try again.
median([1]) resulted in an error: ‘list’ object has no attribute ‘len’
<What do you expect to happen instead?>
I need help here obviously. It keeps erroring out. With median[4.5.5.4], it kept returning 4 instead of 4.5. And with median[1], I keep getting the one I mentioned above: median([1]) resulted in an error: ‘list’ object has no attribute ‘len’
Any ideas?
```pythondef median(x):
new_lst = x
s = new_lst.sort() #sortiing list
leng = new_lst.len(s) #getting length
#Below: was getting an error when the list was just a [1] so made the ‘if’ and ‘elif’ to check if length is greater than 1 and then the other half of the argument.
if leng > 1 and leng % 2 != 0:
med = (leng / 2.0)
return med
elif leng > 1 and leng % 2 == 0:
a = (leng / 2.0)
b = a - 1
c = s.index[a]
d = s.index[b]
med = s[c] + s[d] / 2.0
return med
else:
return s
<do not remove the three backticks above>
Thanks in advance for your help!!!