I wrote this code :

```
def median(lst):
lst = sorted(lst)
amo = len(lst)
fin = 0
if amo % 2 == 0:
fin = float(lst[amo / 2] + lst[amo / 2 - 1]) / 2
else:
fin = int(lst[amo / 2])
return fin
```

and then decided to look at solution :

```
def median(lst):
sorted_list = sorted(lst)
if len(sorted_list) % 2 != 0:
index = len(sorted_list)//2
return sorted_list[index]
elif len(sorted_list) % 2 == 0:
index_1 = len(sorted_list)/2 - 1
index_2 = len(sorted_list)/2
mean = (sorted_list[index_1] + sorted_list[index_2])/2.0
return mean
print median([2, 4, 5, 9])
```

but it looks so complex, so I’ve got a question: is my code better??