Friday, 31 July 2026

๐Ÿš€ Day 101/150 – Password Strength Checker in Python

 

๐Ÿš€ Day 101/150 – Password Strength Checker in Python

A strong password helps protect your accounts from unauthorized access. A good password should contain a mix of uppercase letters, lowercase letters, numbers, and special characters, and it should be at least 8 characters long.

In this post, we'll explore four different ways to check password strength in Python.


Method 1 – Check Password Length

The simplest way to check whether a password is strong is by verifying its length.

password = input("Enter your password: ") if len(password) >= 8: print("Strong Password") else: print("Weak Password")





Sample Input

python123

Output

Strong Password

Explanation

  • input() reads the password entered by the user.

  • len() calculates the password length.

  • If the length is 8 or more, the password is considered strong.

  • Otherwise, it is considered weak.


Method 2 – Check for Uppercase, Lowercase, and Digits

Verify that the password contains different types of characters.

password = input("Enter your password: ") has_upper = any(char.isupper() for char in password) has_lower = any(char.islower() for char in password) has_digit = any(char.isdigit() for char in password) if has_upper and has_lower and has_digit: print("Strong Password") else: print("Weak Password")










Sample Input
Python123

Output

Strong Password

Explanation

  • isupper() checks for uppercase letters.

  • islower() checks for lowercase letters.

  • isdigit() checks for numeric digits.

  • any() returns True if at least one matching character is found.

  • The password is strong only if all three conditions are satisfied.


Method 3 – Check for Special Characters

Require the password to include at least one special character.

password = input("Enter your password: ") special = "!@#$%^&*()_+-=[]{}|;:',.<>?/" has_special = any(char in special for char in password) if has_special: print("Password contains a special character.") else: print("Password needs a special character.")










Sample Input
Python@123

Output

Password contains a special character.

Explanation

  • A string of allowed special characters is created.

  • The program checks whether any character in the password belongs to that string.

  • A password with at least one special character is generally more secure.


Method 4 – Complete Password Strength Checker

Combine all the checks into a single program.

password = input("Enter your password: ") special = "!@#$%^&*()_+-=[]{}|;:',.<>?/" if (len(password) >= 8 and any(char.isupper() for char in password) and any(char.islower() for char in password) and any(char.isdigit() for char in password) and any(char in special for char in password)): print("Strong Password") else: print("Weak Password")











Sample Input

Python@123

Output

Strong Password

Explanation

  • The password must be at least 8 characters long.

  • It must contain:

    • At least one uppercase letter.

    • At least one lowercase letter.

    • At least one digit.

    • At least one special character.

  • If all conditions are met, the password is considered strong.


Comparison of Methods

MethodBest For
Check LengthBasic password validation
Character Type CheckChecking letters and numbers
Special Character CheckImproving password security
Complete Password CheckerReal-world password validation

๐Ÿ”ฅ Key Takeaways

  • A strong password should be at least 8 characters long.

  • Include uppercase letters, lowercase letters, digits, and special characters.

  • Functions like isupper(), islower(), isdigit(), and any() make password validation simple.

  • Combining multiple checks provides better password security.

  • Password strength checkers are commonly used in login and registration systems.

Stay tuned for Day 102 of the #150DaysOfPython series! ๐Ÿš€

0 Comments:

Post a Comment

Popular Posts

Categories

100 Python Programs for Beginner (119) AI (337) Android (25) AngularJS (1) Api (7) Assembly Language (2) aws (31) Azure (12) BI (10) book (1) Books (337) Bootcamp (14) C (78) C# (12) C++ (83) cloud (1) Course (88) Coursera (302) Cybersecurity (34) data (10) Data Analysis (46) Data Analytics (31) data management (16) Data Science (420) Data Strucures (18) Deep Learning (215) Django (16) Downloads (3) edx (21) Engineering (15) Euron (30) Events (7) Excel (24) Finance (13) flask (4) flutter (1) FPL (17) Generative AI (77) Git (13) Google (54) Hadoop (3) HTML Quiz (1) HTML&CSS (48) IBM (43) IoT (3) IS (25) Java (99) Leet Code (4) Machine Learning (387) Meta (24) MICHIGAN (5) microsoft (13) Nvidia (8) Pandas (16) PHP (20) Projects (34) Python (1360) Python Coding Challenge (1223) Python Mathematics (11) Python Mistakes (51) Python Quiz (606) Python Tips (100) Questions (3) R (72) React (7) Scripting (3) security (4) Selenium Webdriver (4) Software (21) SQL (55) Udemy (19) UX Research (1) web application (11) Web development (9) web scraping (3)

Followers

Python Coding for Kids ( Free Demo for Everyone)