Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created July 24, 2017 20:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codecademydev/5df0484ef83ac8a5eae3359fa1794eb2 to your computer and use it in GitHub Desktop.
Save codecademydev/5df0484ef83ac8a5eae3359fa1794eb2 to your computer and use it in GitHub Desktop.
Codecademy export
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