Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created July 24, 2017 21:09
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/26ef79b23c514e74ba8ed20952d91b1c to your computer and use it in GitHub Desktop.
Save codecademydev/26ef79b23c514e74ba8ed20952d91b1c to your computer and use it in GitHub Desktop.
Codecademy export
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