-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDay_25.py
42 lines (33 loc) · 1.24 KB
/
Day_25.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
40
41
42
'''
Write a python method to check whether a string is a valid password.
Password rules:-
* Should have atleast one number.
* Should have atleast one uppercase and one lowercase character.
* Should have atleast one special symbol.
* Should be between 6 to 20 characters long.
'''
def chechPass(passwd):
special_symbols = ['$','#','@','%']
val = True
if (len(passwd) < 6) or (len(passwd) > 20):
print(" Password should be between 6 to 20 characters long.")
val = False
if not any(char.isdigit() for char in passwd):
print("Password must have at least one numeral.")
val = False
if not any(char.isupper() for char in passwd):
print("Password must have at least one uppercase letter.")
val = False
if not any(char.islower() for char in passwd):
print("Password must have at least one lowercase letter.")
val = False
if not any(char in special_symbols for char in passwd):
print("Password must have at least one of the $ # @ %")
val = False
if val:
return val
password = input("Enter password: ")
if (chechPass(password)):
print("Password is valid.")
else:
print("Invalid Password")