Python: If-Else Statement

It is a conditional statement used for selection between two set of statements based on the evaluation of test condition. The statements inside the if block are executed only if the evaluated condition is true. Otherwise statements inside the else block are executed. As we have two set of statements to select based on the test condition, it is also called as Two-way selection statement.

Below is the syntax of if-else statement:

Python if-else statement


		print("positive integer")
		print("Not a positive integer")


Not a positive integer

In the if statement will evaluate condition and result as false then it will jump to else block then it will execute statement of else block.