Recently a security committee decided
to enforce the following rules when an employee creates/changes his/her
password.
- The password must contain atleast one special character among # ! _
$ @
- The password must contain atleast two numbers
- The password must contain
atleast one upper case alphabet and one lower case alphabet.
- The password
must have a minimum length of 8.
- The password must have a maximum length of
25.
The program must accept a given password string P as input and check for
these rules and output VALID or INVALID. Boundary Conditions: Length of P is
from 2 to 50.
Input Format:
First line will contain the string value of the
password P
Output Format:
VALID or INVALID based on the check performed by the
program by applying the rules.
Example Input/Output:
Example 2:
Input:
kiC_3b0x3r
Output:
VALID
Example 2:
Input:
m@d31nindia
Output:
INVALID
Explanation: No alphabet in uppercase.
Solution:
s = input().strip()
if 8 <= len(s) <= 25:
n,sp = 0,0
for i in s:
if i in
'0123456789': n += 1
elif i in
'#!_$@': sp += 1
if n >= 2 and
sp >= 1 and (any(x.islower() for x in s)) and (any(x.isupper() for x in s)):
print('VALID')
else:
print('INVALID')
else:
print('INVALID')