Skip to content

Latest commit

 

History

History
 
 

9 - Handling multiple conditions

Handling conditions

Conditional execution can be completed using the if statement. Adding elif allows you to check multiple conditions

if syntax

if expression:
    # code to execute
elif expression:
    # code to execute
else:
    # code to execute

Boolean operators

  • x or y - If either x OR y is true, the expression is executed

Comparison operators

  • < less than
  • < greater than
  • == is equal to
  • >= greater than or equal to
  • <= less than or equal to
  • != not equal to
  • x in [a,b,c] Does x match the value of a, b, or c