def median(lst): sorted(lst) if len(lst) % 2 == 0: med_num = (lst[len(lst)/2] + lst[len(lst)/2 - 1]) / 2.0 return med_num else: return lst[len(lst)/2] Error: Oops, try again. median([4, 5, 5, 4]) returned 5.0 instead of 4.5 Thank you!
Add lst infront of sorted(lst) -
lst = sorted(lst)
I noticed that you used lst but never stated its value.
Hope that helps. Please let me know.
Yeah, I got it. Thank you a lot!
That's great news.
If you feel that your topic was solved, remember to mark it as such. Others might experience the same or similar errors.
Yes, I have done.
This is the first time I create a topic for asking solution here... LOL...
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.