The problem is a result of your if clause. Lets take a look at what we need to do if there is an even amount of numbers. First we need to find the two middle numbers then we have to take the average of those numbers. It looks like that is what you are trying to do with even = num_set[(len(num_set) / 2)].

What that code is doing though, is setting even equal to the value of whatever is occupying that middle place in the list. So when we call median([4, 4, 5, 5]) even will equal 4. This creates a problem when we run the next line because we set result equal to even, which is 4, plus whatever is in the list at the position of even + 1 which equals 5. We only have a list of 4 numbers so it can't grab anything from position 5.

You need to rewrite your code so that you grab from the middle position and then the position one up from that.

Do we need the above line? Answer: No. It is not an accumulator. In both cases in the code where it occurs it is defined with a new assignment.

Three things we need to complete the evaluation:

a sorted sample space (list of data)

a sample size (list length)

a floored middle index

nums = sorted(numbers) # check
n = len(nums) # check
m = n // 2 # check
# or m = int(n / 2)

Now setting up the return value...

if n % 2: return nums[m] # odd length
return float(nums[m - 1] + nums[m]) / 2 # even length

The less variables we involve the simpler will be the solution. Part of simplicity comes from not repeating code patterns (caching repeated expression values) and zeroing in on the logic.

Us beginners are often eager to roll up our sleeves and dig right in. Good on us, but we can save a lot of effort by taking a pencil and paper and sketching out our problem. Our first idea is not necessarily the best, but we need to get those ideas on paper.

The OP code is such an example. Once we set out to refine and simplify (reverse engineering, perhaps?) the fog lifts and the code becomes more concise. It comes with practice.

My apologies for that, I meant median([4,4,5,5]) and was working with those numbers as I wrote my answer so it does not change anything, but I appreciate you pointing that out.