My code got through the test but I am unsure if it I missed any cases that might break the code. I used min() and max() methods to get the median. Please critique my code! Thank you.

```
def median(lst):
result = []
#Create new list for edits
for i in lst:
result.append(i)
#For lists with odd index
if len(result) % 2 != 0:
while max(result) != min(result):
result.remove(max(result))
if max(result) != min(result):
result.remove(min(result))
return result[0]
#For lists with even index
else:
while len(result) > 2:
result.remove(max(result))
if max(result) != min(result):
result.remove(min(result))
return (result[0] + result[1]) / 2.0
print(median([4,5,6,7,]))
```