You just learned how to put one if inside another — and that keeping code flat is usually easier to read. In this exercise you'll do both: first write a real two-level (nested) conditional, then rewrite part of it as a single flat line using and.
Imagine a user is trying to open a control panel. Two things decide what they see: whether their account is active, and whether they're an admin.
Your tasks
Given these starting values:
account_active = True
is_admin = False
1. Write a nested conditional. Put the admin check inside the active check:
- If
account_active is true and is_admin is true, print Admin panel
- If
account_active is true but is_admin is false, print User dashboard
- If
account_active is false, print Account disabled
2. Now write the admin check a second time, but flat — a single if that uses and to test both conditions at once, and prints Admin (flat check) only when the account is active and the user is an admin.
With the starting values (account_active = True, is_admin = False), the nested check prints User dashboard. The flat and check stays silent because the user isn't an admin — that's exactly right.
Expected output
User dashboard
Constraints
- Task 1 must use a nested
if (one if inside another if)
- Task 2 must use the
and operator on a single line
- Match the printed text exactly, including capitalization and spacing
- Don't change the starting values of
account_active or is_admin