Python Selection Control Structures

If-Elif Structure

  • A way to make decisions in your code

  • Allows the program to choose between multiple paths depending on conditions

  • Commands:

    • If

      • Checks the first condition

      • If true, executes its block of code

    • Elif

      • Else-if

      • Checks additional conditions if the previous if or elif conditions were false

      • Comes before else

    • Else

      • Optonal

      • Runs if none of the previous conditions are true