-
-
Save codecademydev/5df0484ef83ac8a5eae3359fa1794eb2 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) | |
first_half=[] | |
j=0 | |
if len(new_list)%2!=0: #Meaning an odd number of numbers | |
return new_list[len(new_list)/2] | |
elif len(new_list)%2 ==0:#Meaning an even number of numbers | |
while j<=(len(new_list)/2): | |
for i in new_list: | |
first_half.append(i) | |
j+=1 | |
return (first_half[j]+new_list[j+1])/2.0 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment