Section 1 - Instruction

Previously, we learned how if-else statements create two distinct paths for our code: one for when the condition is True, and another for when it's False.

Engagement Message

But what if we need to check several different conditions?

Section 2 - Instruction

Imagine checking if a number is positive, negative, or zero. An if-else only gives us two options. We need a way to add more checks!

Engagement Message

Can you think of a sample application where this scenario of needing more checks could come up?

Section 3 - Instruction

This is where elif comes in! It's short for "else if". It lets you test another condition only if the preceding if (or elif) condition was False.

It adds another branch to our decision-making path.

Engagement Message

To help you memorize it, can you name the 3 conditional statements you just learned?

Section 4 - Instruction

You can chain multiple elif statements after an if. An optional at the very end catches anything that didn't match the or any conditions.

Sign up
Join the 1M+ learners on CodeSignal
Be a part of our community of 1M+ users who develop and demonstrate their skills on CodeSignal