Tutorialspoint
Problem
Solution
Submissions

Password Strength Checker

Certification: Intermediate Level Accuracy: 0% Submissions: 0 Points: 10

Write a Python program to create a password strength checker that evaluates the strength of a password based on various criteria. The function should return a strength level (Weak, Medium, Strong, Very Strong) along with specific feedback about what makes the password strong or weak.

Example 1
  • Input: password = "Password123!"
  • Output: "Very Strong"
  • Explanation:
    • Password contains uppercase letters (P).
    • Password contains lowercase letters (assword).
    • Password contains numbers (123).
    • Password contains special characters (!).
    • Password length is 12 characters, which is good.
    • All criteria are met, so it's classified as "Very Strong".
Example 2
  • Input: password = "abc123"
  • Output: "Weak"
  • Explanation:
    • Password contains lowercase letters (abc).
    • Password contains numbers (123).
    • Password lacks uppercase letters and special characters.
    • Password length is only 6 characters.
    • Multiple criteria are missing, so it's classified as "Weak".
Constraints
  • 1 ≤ password.length ≤ 100
  • Password can contain any printable ASCII characters
  • Strength levels: Weak (0-2 criteria), Medium (3 criteria), Strong (4 criteria), Very Strong (5+ criteria)
  • Criteria: length >= 8, uppercase, lowercase, numbers, special characters
  • Time Complexity: O(n)
  • Space Complexity: O(1)
StringsAccentureShopify
Editorial

Login to view the detailed solution and explanation for this problem.

My Submissions
All Solutions
Lang Status Date Code
You do not have any submissions for this problem.
User Lang Status Date Code
No submissions found.

Please Login to continue
Solve Problems

 
 
 
Output Window

Don't have an account? Register

Solution Hints

  • Define criteria for password strength (length, character types)
  • Check if password length is at least 8 characters
  • Check for presence of uppercase letters (A-Z)
  • Check for presence of lowercase letters (a-z)
  • Check for presence of numbers (0-9)
  • Check for presence of special characters (!@#$%^&*)
  • Count how many criteria are met and determine strength level

Steps to solve by this approach:

 Step 1: Initialize score counter to track how many criteria are met.
 Step 2: Check if password length is at least 8 characters and increment score.
 Step 3: Use regular expressions to check for uppercase letters (A-Z).
 Step 4: Use regular expressions to check for lowercase letters (a-z).
 Step 5: Use regular expressions to check for numeric digits (0-9).
 Step 6: Use regular expressions to check for special characters.
 Step 7: Based on total score, determine strength level (Weak/Medium/Strong/Very Strong).

Submitted Code :