0 out of 68 challenges solved

Validate a password

Write a function called validate_password that takes a string as input and returns True if the input string is a valid password, and False otherwise. A valid password must satisfy the following criteria:

  • At least 8 characters long
  • Contains at least one uppercase letter
  • Contains at least one lowercase letter
  • Contains at least one digit
  • Contains at least one special character from the set: !@#$%^&*

Use regular expressions (regex) to validate the password.

Input: "Passw0rd!"
Output: True

import re

def validate_password(password):
    Validates a password based on certain criteria using regex.

        password (str): The input password.

        bool: True if the password is valid, False otherwise.
    # TODO: Implement the validate_password function