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
You are getting the weight, height and bmi, but you are just throwing away the result. These variables are local to the inner function scopes, so they are invisible for your outer function.
Doing:
weigth = getWeight()
height = getHeight()
bmi = calcBMI(weight, height)
Fixes the problem.
Also, a note on squiggly brackets and semicolons; In Python an indented block with the same indentation level is equivalent to a pair of squiggly brackets in other languages. While line breaks translates to semicolons.
a = 1
b = 2
if True:
c = 3
<=>
{
a = 1;
b = 2;
if (True) {
c = 3;
}
}
However, there are a few (convenient) exceptions. Like when a line is ended without a closing parenthesis, no "virtual semicolon" is inserted. Also, an inner Python scope does not hide its local variables to an outer scope unless the scoping is due to a function.