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

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 (>=, <, ==) return True or False directly. String methods like .isupper() and .isdigit() also return booleans:

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_enoughlength >= 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