-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path2.Check Password
26 lines (26 loc) · 909 Bytes
/
2.Check Password
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
"""2. Check Password
Write a function CheckPassword(str) which will accept the string as an argument or parameter and validates the password. It will return 1 if the conditions are satisfied else it’ll return 0?
The password is valid if it satisfies the below conditions:
It should contain at least 4 characters.
At least 1 numeric digit should be present.
1 Capital letter should be there.
Password should not contain space or slash. The starting character should not be a number.
Sample Test Case: Input:
bB1_89
Output:
1
"""
pswrd=input()
if(len(pswrd)>=4):
numeric_count,capital_count,space=0,0,0
for i in pswrd:
if i.isdigit():
numeric_count+=1
if i.isupper():
capital_count+=1
if i==" " or i=="/":
space+=1
if(numeric_count>=1 and capital_count>=1 and space<1 and pswrd[0].isalpha()):
print(1)
else:
print(0)