Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn Navigate the Maze | If-Else Statements
Practice
Projects
Quizzes & Challenges
Quizzes
Challenges
/
Python Ninja
SectionΒ 5. ChapterΒ 4
ninja.py

ninja.py

bookNavigate the Maze

Swipe to show menu

You already know how if and else let the Ninja make decisions. Sometimes, one decision is not enough. In some situations, the Ninja needs to:

  • Check one condition;
  • Based on that result, check another condition.

This is where nested if statements are useful.

What Is a Nested if?

A nested if is an if statement inside another if statement. You can think of it like asking questions step by step: "If this is True, then check something else".

if condition_one:
    if condition_two:
        # Action

The second if is checked only if the first condition_one is True.

Task

Swipe to start coding

Solution

Explore other courses in Catalog

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 5. ChapterΒ 4
ninja.py

ninja.py

Ask AI

expand

Ask AI

ChatGPT

Ask anything or try one of the suggested questions to begin our chat

some-alt