1.0 KiB
1.0 KiB
type, title, xp, duration, difficulty
| type | title | xp | duration | difficulty |
|---|---|---|---|---|
| challenge | The Validator | 75 | 30 | 2 |
The Validator
[INCOMING — Mission Control, Earth]
Cadet, every system that takes user input has to validate it.
Comparison operators (
>=,<,==) returnTrueorFalsedirectly. String methods like.isupper()and.isdigit()also return booleans:len("hello") >= 8 # False "Hello"[0].isupper() # True "abc1"[-1].isdigit() # TrueImplement
validate(pw)that returns a dict with four checks on a non-empty password:
length— char count (int)long_enough—length >= 8(bool)starts_capital— first char uppercase (bool)ends_digit— last char a digit (bool)[END TRANSMISSION]
Your Task
In starter/starter.py, return the dict using len(), >=,
.isupper(), .isdigit().
Objectives
- All four keys present with correct types
validate("Andromeda1")matches the expected dict exactly- Works for any non-empty password