Files
curriculum/1.solar-system/3.strings/04.the-validator/index.md

45 lines
1.0 KiB
Markdown

---
type: challenge
title: "The Validator"
xp: 75
duration: 30
difficulty: 2
---
# The Validator
> **[INCOMING — Mission Control, Earth]**
>
> Cadet, every system that takes user input has to *validate* it.
>
> Comparison operators (`>=`, `<`, `==`) return `True` or `False`
> directly. String methods like `.isupper()` and `.isdigit()` also
> return booleans:
>
> ```python
> len("hello") >= 8 # False
> "Hello"[0].isupper() # True
> "abc1"[-1].isdigit() # True
> ```
>
> Implement `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