Practice · Python

Practice Nested Conditionals

Nest conditionals to express dependent decisions and know when to flatten them with boolean operators instead.

Nested Conditionalswarming python…

Login permission with nested conditionals

Write a function can_login(is_active, is_locked) that returns True only when a player is active and their account is not locked. In all other cases it should return False. For example:

  • can_login(True, False)True
  • can_login(True, True)False

Use nested if statements as shown in the concept description.

Press Run to see output, or Check to grade against the tests.

Want a whole course built around nested conditionals?

Start my path — free

Adaptive practice, streaks, projects with real code review. Free tier gates AI help, never content.