Why doesn't my code work here but does in python IDE?

```
def median(a_list):
A = sorted(a_list)
#Even number must take the average of the two middle numbers
if len(a_list) % 2 == 0:
b = (len(A)) // 2
median_is_even = ( (A[(b)]) + (A[b-1]) ) / 2
return median_is_even
#Odd number list will have only one number in the middle
else:
c = (len(A))//2
median_is_odd = a_list[c]
return median_is_odd
```