forked from codevscolor/codevscolor
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck_password_validity.py
More file actions
43 lines (39 loc) · 983 Bytes
/
check_password_validity.py
File metadata and controls
43 lines (39 loc) · 983 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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# www.codevscolor.com/python-check-validity-password/
#1
import re
#2
while True:
#3
user_input = input("Enter a password : ")
is_valid = False
if (len(user_input)<6 or len(user_input)>12):
#4
print("Not valid ! Total characters should be between 6 and 12")
continue
elif not re.search("[A-Z]",user_input):
#5
print("Not valid ! It should contain one letter between [A-Z]")
continue
elif not re.search("[a-z]",user_input):
#6
print("Not valid ! It should contain one letter between [a-z]")
continue
elif not re.search("[1-9]",user_input):
#7
print("Not valid ! It should contain one letter between [1-9]")
continue
elif not re.search("[~!@#$%^&*]",user_input):
#8
print("Not valid ! It should contain at least one letter in [~!@#$%^&*]")
continue
elif re.search("[\s]",user_input):
#9
print("Not valid ! It should not contain any space")
continue
else:
#10
is_valid = True
break
#11
if(is_valid):
print("Password is valid")