-
-
Save codecademydev/26ef79b23c514e74ba8ed20952d91b1c to your computer and use it in GitHub Desktop.
Codecademy export
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def median(leest): | |
new_list=sorted(leest) | |
if len(new_list)%2!=0: #Meaning an odd number of numbers | |
if len(new_list)==0: | |
return new_list[0] | |
else: | |
return new_list[(len(new_list)/2)-(1/2)] | |
elif len(new_list)%2 ==0:#Meaning an even number of numbers | |
return (new_list[len(new_list)/2-1]+new_list[len(new_list)/2])/2.0 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment