Code Labs: Defensive Design
Master Authentication checks and Validation trap loops.
Interactive Engine
Test simple validation routines below. Try breaking it purposefully!
User Input Required
The Crucible
Prove your knowledge of authentication logic and validation boundaries.
The Gatekeeper
Authentication just confirms identity. Usually utilizing a simple conditional check.
Task: Finish the if/else statement to only print "Access Granted!" if the provided password variable precisely equals "Dragon".
Trapping Outliers
A teenager account needs an age between 13 and 19 inclusive. We use `or` to check if they entered something outside that bound.
Task: Fix the missing while loop statement to correctly trap users who enter an age less than 13 OR greater than 19. E.g. while age < 13 or age > 19:
Impenetrable Defence
Passwords are strings. To check how many characters a string has, we wrap it in the len() command (e.g. len(password)).
Task: Create a full validation loop condition that keeps asking the user for a password as long as the length is strictly less than 8 characters.