Character Sets from the string Module

Medium ⏱ 12 min 48% acceptance ★★★★★ 4.9
Write charset_report(password) using the string module's constants (ascii_lowercase, ascii_uppercase, digits, punctuation) to return a dict of four booleans: lower, upper, digit, symbol — whether the password contains at least one character from each class.

Examples

Example 1
Input
charset_report('Ab3!')
Output
{'lower': True, 'upper': True, 'digit': True, 'symbol': True}
Explanation

One of each class is present.

Constraints

  • Use the string-module constants, not str methods like isdigit on the whole string.
  • Return exactly those four keys.

Topics

Modules & Packagesstring module

Companies

OktaCiscoIBM

Hints

Hint 1

any(c in string.digits for c in password).

Hint 2

Four similar any() expressions complete the dict.

Loading the Python runtime… Run executes your code and shows printed output; Submit checks your function against this problem's examples.