Hey @codenamephil

It makes it easier for us to run your code, and try and recreate errors, if you format it properly on the forum. (Use the â€śpreformatted textâ€ť option at the top of the box )

Your code is failing when the Codecademy SCT tests it by calling `median([1])`

.

Youâ€™ll also be getting an error from the console, pointing you at the source of the error.

Whilst your Traceback will be telling you that the `IndexError`

is here:

```
median += (numbers[index1] + numbers[index2]) / 2.0
```

in actuality, the reason your code is failing the test is due to the integer division youâ€™re using in the test for your `if`

conditional block. The test youâ€™re using is wrong, but Iâ€™ll explain why itâ€™s causing your error as itâ€™s an interesting example of how the traceback is not the be-all and end-all of debugging.

When we pass in the single item list `[1]`

to your function, we know the following will be true:

```
numbers = [1]
len(numbers) = 1
character_nr = 1 # (1 + 1) /2 = 1
index_nr = 0
```

When we reach your `if-else`

block, we have the following condition:

```
if len(numbers) / 2 != 0 # or, if (1 / 2) != 0
```

which we know is going to be evaluated, for a single item list `[1]`

, to `1 / 2`

. In integer division, this works like this:

```
>>> 1 / 2
0
>>>
```

so we go to the `else`

branch of your code, where we calculate and assign the following variables:

```
char1 = character_nr // 1 = 1 / 1 = 1
char2 = char1 + 1 = 1 + 1 = 2
index1 = char1 - 1 = 1 - 1 = 0
index2 = char2 - 1 = 2 - 1 = 1
```

We then attempt to calculate the median by doing:

```
median += (numbers[index1] + numbers[index2]) / 2.0
# which is the same as:
median += (numbers[0] + numbers[1]) / 2.0
```

The problem with this, is that our list `numbers`

has only one element: `[1]`

. So, there is no item with an index of `1`

, and we get the `IndexError`

that youâ€™re seeing back from Python.

This is a good example of a case where the Traceback is showing you where Python has fallen over, but where the actual problem is elsewhere in the code.

Iâ€™ve explained where your code is going wrong; can you see how you need to fix it?