Exercise 4: A Password Chooser That Names the Rules You Broke — Possible Solution ==================================================================== accepted = False while not accepted: password = input("Choose a password: ") problems = [] if len(password) < 8: problems.append("at least 8 characters") if not any(ch.isdigit() for ch in password): problems.append("at least one digit") if " " in password: problems.append("no spaces") if problems: print("Rejected. It needs: " + ", ".join(problems)) else: print("Password accepted") accepted = True Example run: Choose a password: abc Rejected. It needs: at least 8 characters, at least one digit Choose a password: abcdefgh Rejected. It needs: at least one digit Choose a password: abcd efg1 Rejected. It needs: no spaces Choose a password: secret123 Password accepted WHY THIS WORKS AS AN ANSWER ------------------------------ The flag starts as False, so the loop runs at least once, and the only way the condition can ever become false is the accepted = True line in the else branch. Rules are checked separately and independently, with no elif, so one attempt can break several rules and every one of them is reported. problems is created fresh at the start of every pass, which matters: created outside the loop, old problems would still be listed on the next attempt. any() with a generator expression is True if at least one character is a digit.