def median(listof):
listof = sorted(listof)
if len(listof) % 2 == 1:
return listof[len(listof)//2]
else:
middleposition1 = listof[len(listof)//2-1]
middleposition2 = listof[len(listof)//2+1]
Median = (middleposition1 + middleposition2)/2
return Median
print(median([4, 5, 5, 4]))
ZGVmIG1lZGlhbihsaXN0b2YpOgogICAgbGlzdG9mID0gc29ydGVkKGxpc3RvZikKICAgIGlmIGxlbihsaXN0b2YpICUgMiA9PSAxOgogICAgICAgIHJldHVybiBsaXN0b2ZbbGVuKGxpc3RvZikvLzJdCiAgICBlbHNlOgogICAgICAgIG1pZGRsZXBvc2l0aW9uMSA9IGxpc3RvZltsZW4obGlzdG9mKS8vMi0xXQogICAgICAgIG1pZGRsZXBvc2l0aW9uMiA9IGxpc3RvZltsZW4obGlzdG9mKS8vMisxXQogICAgICAgIE1lZGlhbiA9IChtaWRkbGVwb3NpdGlvbjEgKyBtaWRkbGVwb3NpdGlvbjIpLzIKICAgICAgICByZXR1cm4gTWVkaWFuCnByaW50KG1lZGlhbihbNCwgNSwgNSwgNF0pKQ==