How to indent multiple if...else statements in Python?

PythonServer Side ProgrammingProgramming

Use of indented blocks is an important feature of Python. Indent level of the block is more than previous statements. Hence, if multiple if statements are present in a program in nested fashion, each subsequent indented block will have increasing level of indent.

if expr1==True:
    if expr2==True:
        stmt1
    else:    
     if expr3==True:
        stmt2
else:
    if expr3==True:
       stmt3
    else:
       stmt4
raja
Published on 15-Feb-2018 01:00:46
Advertisements