-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpassword_strength_checker.py
More file actions
59 lines (52 loc) · 1.77 KB
/
Copy pathpassword_strength_checker.py
File metadata and controls
59 lines (52 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import string
print("Welcome to the Password Strength Checker!")
password_checks=0
feedback=[]
password=input("Please enter your password: ")
#check 1 : length
if len(password) >= 10:
print(" ✅ Your password is long enough.")
password_checks += 1
else:
print("Your password is too short. It should be at least 10 characters long.")
feedback.append("Password too short.")
# check 2 : Uppercase
if any(char.isupper() for char in password):
print(" ✅ Your password contains uppercase letters.")
password_checks += 1
else:
print("Your password should contain at least one uppercase letter.")
feedback.append("Missing uppercase letter.")
# check 3 : Lowercase
if any(char.islower() for char in password):
print(" ✅ Your password contains lowercase letters.")
password_checks += 1
else:
print("Your password should contain at least one lowercase letter.")
feedback.append("Missing lowercase letter.")
# check 4 : Digits
if any(char.isdigit() for char in password):
print(" ✅ Your password contains digits.")
password_checks += 1
else:
print("Your password should contain at least one digit.")
feedback.append("Missing digit.")
# check 5 : Special characters
if any(char in string.punctuation for char in password):
print("✅ Password has symbols!")
password_checks += 1
else:
feedback.append("❗ Add symbols like @, #, !, etc.")
#final analysis
print("\n final analysis:")
if password_checks ==5:
print("Your password is strong! ✅")
else:
print("Your password is weak. ❌")
print("Feedback:")
for item in feedback:
print("-", item)
if feedback:
print("\nPlease consider the feedback to improve your password strength.")
for item in feedback:
print("-", item)