Skip to main content
Problem 3

Password Strength Tagger

EASYBUILD
Strings+2

Implement tag_password_strength(password) that returns a strength label. Return "invalid" if the password contains any whitespace. Otherwise, count how many character categories appear: lowercase, uppercase, digit, symbol. Return "strong" only if len >= 12 and at least 3 categories appear. Return "medium" only if 8 <= len <= 11 and at least 2 categories appear. Return "weak" for all remaining valid passwords.

Requirements
  • Whitespace makes the password invalid before any strength rules are applied.
  • Character categories are lowercase, uppercase, digit, and symbol.
  • A symbol is any non-whitespace ASCII character that is not a lowercase letter, uppercase letter, or digit.
  • "medium" is limited to passwords with length from 8 through 11 inclusive.
  • Valid passwords with length >= 12 still return "weak" unless they have at least 3 categories.
Examples
Example 1
Input
password = "Abcdef12"
Output
"medium"
Note

Length 8, contains uppercase, lowercase, and digits — 3 categories.

Example 2
Input
password = "Abc 12345"
Output
"invalid"
Note

Contains whitespace.

Example 3
Input
password = "abcdefgh1234"
Output
"weak"
Note

Length 12, but only lowercase and digit categories appear. It does not qualify as strong, and medium only applies to lengths 8 through 11.

Constraints
  • 0 <= len(password) <= 200
  • password may contain any ASCII characters
Follow-up

How would you change the rules so password strength can be configured with custom length thresholds and required category counts?

Hints
Related Practice
Track
Backend Basics

Keep moving through related backend basics problems and build a stronger search-friendly practice loop around this topic.

View track →
Console output will appear here...