Https://www.codecademy.com/courses/learn-python/lessons/practice-makes-perfect/exercises/median


#1

<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.>

<In what way does your code behave incorrectly? Include ALL error messages.>
Hello, I just can get past this exercise. Can somebody be so kind and point me to the right direction? I tried many ways and uploaded a screenshot of my latest attempt. I don’t know what i’m missing here…

<What do you expect to happen instead?>
1.
Write a function called median that takes a list as an input and returns the median value of the list. For example: median([1, 1, 2]) should return 1.
The list can be of any size and the numbers are not guaranteed to be in any particular order. Make sure to sort it!
If the list contains an even number of elements, your function should return the average of the middle two

```python

<do not remove the three backticks above>

#2

difficult to tell from an image when you can’t run the code

i would guess half which you define on line 3 is the value from the list, not the index.

yet youse half as index on line 5, this can’t be. half is already value from the list


#3

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