seed: curriculum content
This commit is contained in:
44
1.solar-system/3.strings/04.the-validator/index.md
Normal file
44
1.solar-system/3.strings/04.the-validator/index.md
Normal file
@@ -0,0 +1,44 @@
|
||||
---
|
||||
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
|
||||
Reference in New Issue
Block a user