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 so that the program runs inside a while loop that evaluates a zero string to exit BUT all input and calculations must be inside functions.
I've got this far, but the weight, height, and bmi variables are throwing undefined errors. Problem is, as far as I know, didn't I define them already in their functions?
NameError: name 'weight' is not defined
So, I thought, maybe it's because I need to indent the function calls to give the variable declarations a higher scope and what do you know! the evil red squiggly underline went away. So I ran the program with no errors and but nothing ran inside the while loop. it ignored everything! ugh....
Any help please. God, I love squiggly brackets and semicolons.
def BMICalculator():student_name = input("Enter the student's name or 0 to exit:")while student_name != "0":def getWeight():weight = float(input("Enter " + student_name + "'s weight in pounds: "))return weightdef getHeight():height = float(input("Enter " + student_name + "'s height in pounds: "))return heightdef calcBMI(weight, height):bmi = (weight * 703) / (height * height)return bmigetWeight()getHeight()calcBMI(weight, height)print("\n" + student_name + "'s BMI profile:")print("---------------")print("Height:", height, "\nWeight:", weight)def showBMI(bmi):print("BMI Index:", "{:.2f}".format(bmi))showBMI(bmi)student_name = input("Enter next student's name or 0 to exit:")print("\n\nExiting Program!")BMICalculator()