The calculation function doesn't return anything.
You can add the planet as a parameter and create a dict.
You can add the planet as a parameter and create a dict.
lbs = ask_weight() def calculation(lbs, planet): mass = lbs/9.807 weight = { 'mercury': mass*3.7, 'venus':mass*8.87, 'mars': mass*3.71, 'jupiter': mass*24.92, 'saturn': mass*10.44, 'uranus': mass*8.87, 'neptune': mass*11.15, 'pluto': mass*0.58} # pluto. Actually Pluto is no more a part of the nine. http://www.bbc.com/news/science-environment-33462184 return weight[planet] def ask_weight(): lbs = float(input("How many pounds do you weigh? ")) return lbs # the function have to return a value. lbs is a local to the fuction variable. def ask_planet(): planet = input("Which planet would you like to know your weight for? ") return planet # same hereAnd then:
planet = ask_planet().lower() lbs = ask_weight() # if is not needed because we have a dict and we using the planet name to determine the desired value print("Your weight on {} would be {} pounds.".format(planet.title(), calculation(lbs, planet))