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

Hi everyone! I've got past the median lesson, but I'm confused as to why. I use the code

```
def median(blergh):
x = sorted(blergh)
median = 0
if len(x) % 2 != 0:
median = x[(len(x) - 1) / 2]
elif len(x) % 2 == 0:
median = (x[(len(x)/2)] + x[len(x)/2 - 1]) / 2
return median
```

then, it doesn't work; I get the error:

Oops, try again. median([4, 5, 5, 4]) returned 4 instead of 4.5

then, I try the code

```
def median(blergh):
x = sorted(blergh)
median = 0
if len(x) % 2 != 0:
median = x[(len(x) - 1) / 2]
elif len(x) % 2 == 0:
median = (x[(len(x)/2)] + x[len(x)/2 - 1]) / (2.0)
return median
```

and this works; all I did was replace the 2 in line 7 with a 2.0. What I suspect is that I can't divide by an integer, and perhaps the len() function works only with a float, for some reason. Is this on the right track? In any case, what I'd like to know is why replacing the 2 with a 2.0 changes the way the median is calculated, and why it ends up working. Thank you so much for your time!