Selecting the right else statement depending on user input
<p>I'm working on a little program where the user inputs a price and then the program would output the shipping cost based on the input.</p>

<pre><code>#Initilaize variables

lowUS = 6.00;
medUS = 9.00;
highUS = 12.00;
lowCan = 8.00;
medCan = 12.00;
highCan = 15.00;

#Greet user and ask for input
print("Welcome to Ben's shipping calculator!");
print("We will calculate your shipping cost for you!");


orderTotal = float(input("Please input your total amount."));
country = input("In which country do you reside? Please type C for Canada or U or USA. ");

#Validate input
while country not in {'u', 'c', 'C', 'U'}:
    print ("Invalid input. Please try again. ")
    country = input("In which country do you reside? Please type C for Canada or U or USA. ");

#Determine how much the shipping fee is
if country == 'U' or country == 'u':
    if orderTotal &lt;= 50.00:
        if orderTotal &gt; 50.00 and orderTotal &lt;= 100.00:
            if orderTotal &gt; 100.00 and orderTotal &lt;= 150.00:
                if orderTotal &gt; 150.00:
                    print("Your shipping is free and your grand total is", orderTotal)
                else:
                    print("Your shipping fee is: ", highUS);
                    orderTotal = (orderTotal + highUS); 
            else:
                print("Your shipping fee is: ", medUS);
                orderTotal = (orderTotal + medUS);
        else:
            print("Your shipping fee is: ", lowUS);
            orderTotal = (orderTotal + lowUS);

elif country == 'c' or country == 'C':
    if orderTotal &lt;= 50.00:
        if orderTotal &gt; 50.00 and orderTotal &lt;= 100.00:
            if orderTotal &gt; 100.00 and orderTotal &lt;= 150.00:
                if orderTotal &gt; 150.00:
                    print("Your shipping is free and your grand total is", orderTotal)
                else:
                    print("Your shipping fee is: ", highCan);
                    orderTotal = (orderTotal + highCan); 
            else:
                print("Your shipping fee is: ", medCan);
                orderTotal = (orderTotal + medCan);
        else:
            print("Your shipping fee is: ", lowCan);
            orderTotal = (orderTotal + lowCan);

print("Your grand total is: $", orderTotal);
</code></pre>

<p>I am very new to python and programming and I'm not sure if this is a good way to go at it, but I'm learning if-else statements so I thought I would give it a try. So far it only works if you input "50" for the amount. It will calculate based off of the country only for "50". I'm not sure where I went wrong, if someone could help and explain, that would be great.</p>

<p>Your logic is a bit screwy. If the amount is &lt;= $50, then it is not > $50 or &lt;= $100, so anything following that nested "if" will never execute:</p>

<pre><code>if orderTotal &lt;= 50.00:
    if orderTotal &gt; 50.00 and orderTotal &lt;= 100.00:
        # ** this will never run **
    else:
        # This will run, if orderTotal &lt;= 50.00
</code></pre>

<p>Nothing will happen if <code>orderTotal &gt; 50.00</code>, because there's no <code>else</code> for the <code>if orderTotal &lt;= 50.00</code> test. @Jon Clements' answer shows the correct way to structure your code.</p>

python variables if-statement