def
password_check(passwd):
SpecialSym
=
[
'$'
,
'@'
,
'#'
,
'%'
]
val
=
True
if
len
(passwd) <
6
:
print
(
'length should be at least 6'
)
val
=
False
if
len
(passwd) >
20
:
print
(
'length should be not be greater than 8'
)
val
=
False
has_digit
=
False
has_upper
=
False
has_lower
=
False
has_sym
=
False
for
char
in
passwd:
if
ord
(char) >
=
48
and
ord
(char) <
=
57
:
has_digit
=
True
elif
ord
(char) >
=
65
and
ord
(char) <
=
90
:
has_upper
=
True
elif
ord
(char) >
=
97
and
ord
(char) <
=
122
:
has_lower
=
True
elif
char
in
SpecialSym:
has_sym
=
True
if
not
has_digit:
print
(
'Password should have at least one numeral'
)
val
=
False
if
not
has_upper:
print
(
'Password should have at least one uppercase letter'
)
val
=
False
if
not
has_lower:
print
(
'Password should have at least one lowercase letter'
)
val
=
False
if
not
has_sym:
print
(
'Password should have at least one of the symbols $@#'
)
val
=
False
return
val
print
(password_check(
'Geek12@'
))
print
(password_check(
'asd123'
))
print
(password_check(
'HELLOworld'
))
print
(password_check(
'helloWORLD123@'
))
print
(password_check(
'HelloWORLD123'
))