The “If” statement that written inside an “if” statement is called a nested if statement.
Sometimes you may have to check for the situation inside the if statement after the “if” condition becomes true. You can use a nested if statement in these cases. “nested if” statement is used when the decision of the second statement depends on the statement of the first statement.
You can use if, elif, and else statement inside the if statement. This will also count towards the nested if statement.
E.g., if(condition1) { if(condition2) { } elif (condition3) { } else { } }
Any number of these statements can be put inside one another. Indentation is the only way to figure out the spaces in the nesting level, which means multiple if-else statements inside other if-else statements.
Knowledge2life website
Knowledge2life 1
Knowledge2life website
Knowledge2life 1
Knowledge2life 3
|