-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheck_password.py
39 lines (31 loc) · 953 Bytes
/
check_password.py
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
"""
This program check if a password is good by using the following criteria:
- It must contain at least 8 characters.
- It must contain at least one uppercase letter.
- It must contain at least one lowercase letter.
- It must contain at least one number.
Input: String
Output: Boolean
"""
def check_password(password):
# Initialize state variables.
uppercase = False
lowercase = False
digit = False
# Check for password compliance with specification.
for char in password:
if char.isupper():
uppercase = True
if char.islower():
lowercase = True
if char.isdigit:
digit = True
return (len(password) >= 8 and uppercase and lowercase and digit)
def main():
password = input("Enter passsword: ")
if check_password(password):
print("The password is good!")
else:
print("The password is bad!")
if __name__ == '__main__':
main()