← Back to challenges

Password Validation

PythonHardvalidationconditionsregex

Instructions

Create a function that validates a password to conform to the following rules:

  • Length between 6 and 24 characters.
  • At least one uppercase letter (A-Z).
  • At least one lowercase letter (a-z).
  • At least one digit (0-9).
  • Maximum of 2 repeated characters.
    • "aa" is OK 👍
    • "aaa" is NOT OK 👎
  • Supported special characters:
    • ! @ # $ % ^ & * ( ) + = _ - { } [ ] : ; " ' ? < > , .

Examples

validate_password("P1zz@") ➞ False
// Too short.

validate_password("iLoveYou") ➞ False
// Missing a number.

validate_password("Fhg93@") ➞ True
// OK!

Notes

N/A

python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.