1. Learn
  2. /
  3. Courses
  4. /
  5. Intermediate Python for Developers

Connected

Exercise

Building a password validator

Your team is developing an authentication system for a website. To ensure user accounts are secure, you need to create a validate_password() function that checks if passwords meet minimum security requirements. The function should verify that a password is at least eight characters long and contains at least one special character from the string module's punctuation collection.

The string module and a test password variable user_password are already imported for you.

Instructions

100 XP
  • Complete the validate_password() function to check if the password is at least 8 characters long.
  • Add a loop to check if any character in the password exists in string.punctuation.
  • Call the function with user_password, and store the result in is_valid.