Password rule checker

Mediumanystring methodslists· 20 XP

The sign-up form shows a message for every rule a password breaks. The rules, in this order, are:

  1. "length": at least 8 characters
  2. "digit": at least one digit
  3. "upper": at least one upper-case letter
  4. "space": no spaces

Write a function broken_rules(password) that returns a list of the names of the rules the password breaks, in the order above. A password that passes everything gives an empty list.

How it's checked

Your code runs, then the check below runs and its printed output is compared with ours.

  • broken_rules("hello world") returns ["digit", "upper", "space"]

Hints, the later steps and the answer come with Pro.

def broken_rules(password):
    ...