 In Python, you can put if statements inside of if statements, and that's called a nested if. Here's a program that asks for a price and quantity, and calculates the subtotal, tax, and total, and prints them out. Let's run it. If I have a unit price of $4.50, and I order seven of them, there's my subtotal, tax, and total purchase price. I'd like to be sure that both the price and quantity are greater than zero. Let's add an if else for the price. After I get the price, I put an if statement. If price is greater than zero, then I want to do all the rest of the code. These lines need to be indented. I could indent them one by one by hand, but Thani helps me out. When I highlight all the lines and press Tab, Thani indents them all for me. If the price is greater than zero, I continue with the rest of the code. Otherwise, I print a message. Price must be greater than zero. By the way, error messages should be meaningful. Instead of printing a message like invalid input, which doesn't help anyone, let the user know why the input is bad so that they can fix it. Let's run the program again. If I enter a unit price of $4.95, it'll tell me right away that the price must be greater than zero. That handles negative prices. But what about negative quantities? If I give a valid unit price and then a negative quantity, it still goes through with the bad calculation. I need another if else to handle that. After I get the quantity, I have to ask another question, namely if the quantity is greater than zero. If that's the case, I'm able to do all these things. They need to be indented. Pressing Tab will indent them for me. Otherwise, the quantity is less than or equal to zero, and I print quantity must be greater than zero. Let me move this down so you can see the whole program. And you'll see that I have this if statement inside of this if statement. That's my nested if. Let's run the program again. With a valid unit price and a valid quantity, everything works nicely. With an invalid price, I get an error right away. With a valid price and a negative quantity, I get the appropriate error message as well. The program is now working the way I want it to because I have a nested condition, an if within an if. Can you put an if statement inside the else clause? Yes, you can. Here's another way I could have written the program. In this program, I'm asking for both the price and the quantity before I do any testing. Then I ask, are both the price and quantity greater than zero? I'm using the logical operator and to make a compound condition. If both of them are okay, it's okay to do the rest of the calculations in printing. Otherwise, one or both of the price or quantity must be wrong. Here, I have two separate if statements inside the else clause, and I'm going to put in a blank line for readability here. The first if statement says if the price is less than or equal to zero, that's an error. Separately, I ask if the quantity is less than or equal to zero, and if so, I print an appropriate error message there. Although these if statements don't need an else clause, if you'd like to have one, you can put one in and say pass to do nothing. And I'll put one in here as well. Now let's test the program. If I give a valid price and quantity, everything works fine. If I give an invalid price but an okay quantity, I get the price error message with a valid price and an invalid quantity, I get the quantity error message, and if both my inputs are invalid, I get both error messages. There's an important point here. In order to do a good test of a program, you have to test all the combinations of good and bad input to make sure you've covered all the cases. Another thing to notice is the difference between this program and the first one. In the first version of the program, I gave an error message as soon as I found an error. In the other program, I wait until I have all the input before I give any of the error messages. Which approaches better? That's a design decision. The takeaway from this video is that it's possible to have if statements inside of if statements. You can put if statements inside of else clauses, and when the occasion warrants it, you can even have an if and else inside the if and another if and else inside the else clause. Whatever the design of the program requires, you may nest ifs inside of one another to get the effect you need.