The "if" logical operator can contain code that includes more "if" logical operators. Here's what your program should look like if you check for conditions using nested logical operators:
if (first condition):
if (second condition):
(conditionally executed code)
If the first condition is not met, the nested "if" will not be checked at all. If the nested condition is not met, the conditionally executed code will not be executed. This way the code is executed when both conditions are met.
This method can be applied for more than two conditions.
Pay attention to the levels of code indentation. If both "if" operators are on the same indentation level, they won't be codependent:
if (first condition):
if (second condition):
(conditional code)
This is an example of incorrectly written code.