SectionΒ 5. ChapterΒ 4
ninja.py
Navigate 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
Everything was clear?
Thanks for your feedback!
SectionΒ 5. ChapterΒ 4
ninja.py
Ask AI
Ask AI
Ask anything or try one of the suggested questions to begin our chat