Python Nested If


If Inside If

You can have if statements inside if statements, this is called nested if statements.

Example

x = 41

if x > 10:
  print("Above ten,")
  if x > 20:
    print("and also above 20!")
  else:
    print("but not above 20.")
Try it Yourself »


Copyright 1999-2023 by Refsnes Data. All Rights Reserved.