Nested if-else Conditional Statement in python
General Form of if- elif-else Conditional Statement:
In this statement, I discussed nested if-else in python.
The general form of if-elif-else statement is as follows:
if < conditional >:
<Sequence S1, of statements to be executed >
elif < condition2 >:
< Sequence S2 of statements to be executed >
elif < condition3 >:
<Sequence S3, of statements to be executed >
.
.
.
else:
<Sequence Sn of statements to be executed >
In the above description, elif is an abbreviation used in Python for else if. By now, it must be clear that the clauses elif and else of the if statement is optional, and that the sequence of statements defined under a clause is executed in a sequence. As the physical alignment of statements determines which statements form a block of code, one needs to be very careful about indentation while writing Python programs.
if elif else python Conditional Statement:
Sometimes, we need a control structure within another control structure. Such a mechanism is called nesting. For example, the function maximum3 Fig.2 ) finds the maximum of three numbers using nested structure. Here, and if clause has been used within another if clause. First, we test whether n1 is greater than n2. If so, the condition n1 n3 is evaluated, and if True, n1 is declared as the maximum number. The other cases are dealt with similarly.
complete this article at this link https://protechcoder.com/2021/08/03/nested-if-else-in-python/kamranabbasi9145/