I\'m taking a tutorial in udemy to teach myself Python and it is making me love Javascript every day more. Anyhow, I can\'t seem to figure out how to work this indentation right
didn't I define them already in their functions
Yes, and that's the problem. They are locally scoped to those functions. You need assignment... weight = getWeight()
, for example
No need to go overboard with the function definitions, though
def calcBMI(weight, height):
bmi = (weight * 703) / (height * height)
return bmi
def showBMI(bmi):
print("BMI Index:", "{:.2f}".format(bmi))
student_name = input("Enter the student's name or 0 to exit:")
while student_name != "0":
weight = float(input("Enter " + student_name + "'s weight in pounds: "))
height = float(input("Enter " + student_name + "'s height in pounds: "))
bmi = calcBMI(weight, height)
# etc...
showBMI(bmi)
student_name = input("Enter next student's name or 0 to exit:")
print("\n\nExiting Program!")