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
26 lines (23 loc) · 823 Bytes
/
password.py
File metadata and controls
26 lines (23 loc) · 823 Bytes
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
import re
password=input("enter password:")
def Password(password):
x=True
while x:
if len(password)<6 or len(password)>16 :
raise ValueError("Password has to between 6-16 characters.")
elif not re.search("[a-z]",password):
raise ValueError ("Password must have at least 1 letter between [a-z]")
elif not re.search("[A-Z]",password):
raise ValueError("Password must have at least 1 letter between [A-Z]")
elif not re.search("[0-9]",password):
raise ValueError("Password must have at least 1 number between [0-9]")
elif not re.search("[$#@]",password):
raise ValueError("Password must have at least 1 charachter between [$#@]")
else:
print("Congratulations,Valid Password")
x=False
break
try:
Password(password)
except ValueError as V :
print(V)