Jump to content

TroyL99

Members
  • Posts

    1
  • Joined

  • Last visited

Posts posted by TroyL99

  1. The following code reason doesn't make sense.

    If x = 41 and I check if its greater than 10 and 20, why would I print out "but not above 20." x is greater than 20 and it's greater than 30 and 40 as well. 

    Perhaps w3schools could use a better example for beginners to make it more clear. 

    Thank you!

    Nested 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.")

     

×
×
  • Create New...