Track 3 · Lesson 7 of 11
Nested conditions and guard clauses
Put decisions inside decisions when a second question only makes sense after the first, and flatten deep nesting with guard-style elif chains.
You will be able to
- Write an if statement inside another if or else block
- Read indentation to tell which else belongs to which if
- Flatten nested decisions into an elif chain that handles problems first
- Decide when nesting is clearer than combining conditions with and
Included with a Formula Quest membership
It has 4 graded exercises with feedback, hints and solutions. Python Quest is included in Formula Quest memberships that cover Python; membership and billing are managed on Formula Quest.
View Formula Quest memberships
Tracks 1 and 2, the first lesson of every track, the playground and the dataset library are free.