If, Elif and Else

If, Elif and Else
Figure: If, Elif and Else

If

The If statement performs an action(s) if the condition is true; otherwise, it skips the action(s).

Elif

The Elif statement is an extension of the If statement and may only be used following it.

When used together, the statements perform an action(s) if the condition is true; otherwise, the Elif statement checks for the second condition. If the second condition is true, it performs an action(s); otherwise, it skips the action(s).

This statement is used to create multiple levels of conditionals with a hierarchy that determines the sequence of checks performed.

Else

The Else statement is an extension of the If or Elif statement and may only be used following either.

When used together, the statements perform an action(s) if the condition is true; otherwise, it performs a different action(s) over the items that are excluded from the first condition.

results matching ""

    No results matching ""