forked from fenyx-it-academy/Class5-Python-Module-Week4
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpassword.py
More file actions
23 lines (21 loc) · 933 Bytes
/
password.py
File metadata and controls
23 lines (21 loc) · 933 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import re
def password_validity():
password = input("enter a valid password")
charRegex = re.compile(r'(\w{6,16})')
lowerRegex = re.compile(r'[a-z]+')
upperRegex = re.compile(r'[A-Z]+')
digitRegex = re.compile(r'[0-9]+')
chaRegex = re.compile(r'[#@$]+')
if charRegex.findall(password)== []:
raise ValueError('The password must be between 6 and 16 characters.')
elif lowerRegex.findall(password)==[]:
raise ValueError('There should be lowercase letter.')
elif upperRegex.findall(password)==[]:
raise ValueError('There should be uppercase letter.')
elif digitRegex.findall(password)==[]:
raise ValueError('There should be at least one digit.')
elif chaRegex.findall(password)==[]:
raise ValueError('There should be at least one of the shown special symbols.')
else:
print('Valid password')
password_validity()