Python If-else Condition Example


  • If-else statement

It checks first for if condition, if the condition is true, it will execute if block, otherwise it will execute else block.

Program
a = 2 b = 7 if b > a: print("b is greater than a") else: print("a is greater than b")
Input
Output