Python If-else Condition Shorthand 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.

In shorthand , it can also be written as

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