Example:

```
n = [ 2, 5, 9, 3, 7, 6, 8 ]
n.sort()
print n # [ 2, 3, 5, 6, 7, 8, 9 ]
j = len(n)
print j # 7
j /= 2
print j # 3.5
k = int(j)
print k # 3
```

Since `k`

< `j`

,

```
# [ 2, 3, 5, 6, 7, 8, 9 ]
# ^
# |
# index 3
```

The median, then, is `6`

.

```
n = [ 2, 8, 5, 9, 3, 7, 6, 8 ]
n.sort()
print n # [ 2, 3, 5, 6, 7, 8, 8, 9 ]
j = len(n)
print j # 8
j /= 2
print j # 4
k = int(j)
print k # 4
```

Since `j == k`

,

```
# [ 2, 3, 5, 6, 7, 8, 8, 9 ]
# ^ ^
# | |__
# | index 4 (k==4)
# index 3 (k - 1)
```

So the median, then, is

```
m = (n[4] + n[3]) / 2. # (7 + 6) / 2. => 13 / 2.
print m # 6.5
```

For the record, dividing by a float yields a float. `n / 2.`

is a Python shortcut.