-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpassword_strength.py
More file actions
42 lines (34 loc) · 1.12 KB
/
Copy pathpassword_strength.py
File metadata and controls
42 lines (34 loc) · 1.12 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
password = input("Enter a password: ")
if len(password) > 8:
print("Length is good.")
else:
print("Too short.")
for char in password:
if char.isupper():
print("Contains uppercase letter.")
break
else: print("No uppercase letter found.")
for char in password:
if char.islower():
print("Contains lowercase letter.")
break
else: print("No lowercase letter found.")
for char in password:
if char.isdigit():
print("Contains a digit.")
break
else: print("No digit found.")
import string
for char in password:
if char in string.punctuation:
print("Contains a special character.")
break
else: print("No special character found.")
all_conditions_met = (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 string.punctuation for char in password))
if all_conditions_met:
print("Password is strong.")
else: print("Password is weak.")