Validate · Medium

Check a password

A password is valid only if it has at least 8 characters, at least one capital letter, at least one digit, and no spaces.

Task

Write a prompt that checks one password.

Output format

VALID or INVALID: <reasons>

  • Reasons, in this order, separated by ", ": TOO SHORT, NO UPPERCASE, NO DIGIT, HAS SPACE.
  • List every reason that applies.

Your prompt must contain {input}: it is replaced by each test case, just like the hidden tests in a hiring test.

Sample case 1
Input
Sunshine2026
Output
VALID
Sample case 2
Input
sunshine
Output
INVALID: NO UPPERCASE, NO DIGIT

There are 5 test cases in all; the others are like hidden tests: work out what tricky inputs they might use!

Loading the editor…