File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed
Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change 1+ import string
2+
3+ def check_password_strength (password ):
4+ strength = 0
5+
6+ # Criteria 1: Length (Must be at least 8 characters)
7+ if len (password ) >= 8 :
8+ strength += 1
9+
10+ # Criteria 2: Must contain Digits (0-9)
11+ has_digit = False
12+ for char in password :
13+ if char .isdigit ():
14+ has_digit = True
15+ break
16+ if has_digit :
17+ strength += 1
18+
19+ # Criteria 3: Must contain Uppercase Letters (A-Z)
20+ has_upper = False
21+ for char in password :
22+ if char .isupper ():
23+ has_upper = True
24+ break
25+ if has_upper :
26+ strength += 1
27+
28+ return strength
29+
30+ if __name__ == "__main__" :
31+ print ("--- Password Strength Checker ---" )
32+ # Note: We cannot run input() on the website, but this code is correct.
33+ # If users download it, it will work.
34+ print ("Run this script locally to test your password!" )
You can’t perform that action at this time.
0 commit comments