Advertisement



< Prev
Next >



Python Nested If Statement





Like other programming languages, Python also provides us a nested-if decision-making conditional statement, in which the if statement is nested inside another if statement(a parent if condition), hence it is named, the nested if.




Working of nested if









Important points about conditional statements in Python







nested if example


# Python - nested if statement 


if(99<100):
	if(99<101): # This is a nested if 
		print("99 is less than 100 & 99 is also less than 101")


Output


99 is less than 100 & 99 is also less than 101


Program Analysis





Advertisement




nested if example with an optional else


# Python - nested if statement  with optional else


if(99>100):
	if(99<101): # This is a nested if 
		print("99 is less than 100 & 99 is also less than 101")

else:		    # An optional else statement
	print("99 is not greater than 100");


Output


99 is not greater than 100


Program Analysis






Please share this article -





< Prev
Next >
< Python elif statement
Python nested if else statement>



Advertisement

Please Subscribe

Please subscribe to our social media channels for daily updates.


Decodejava Facebook Page  DecodeJava Twitter Page Decodejava Google+ Page




Advertisement



Notifications



Please check our latest addition

C#, PYTHON and DJANGO


Advertisement