I need help to solve a code to check for valid password and condition are:
The password should be of at least eight characters.
It is a combination of alphabets, numeric digits
0
to9
, and special characters'_'
,'@'
,'#'
, and'*'
. No other character is allowed.It should contain one capital alphabet, one special character from (
'_'
,'@'
,'#'
,'*'
), and one numeric digit from0
to9
.
temp_list=['_','@', '#','*']
flag=False
for a in range (6):
try:
pas=list(input("enter password :"))
except ValueError:
continue
if len(pas)<8:
print("try again")
continue
elif len(pas)>8:
for j in range(10):
for t in temp_list:
if str(j) in pas and t in pas:
flag=True
continue
else:
flag=False
break
if a<5:
if str(j) not in pas or t not in pas:
print("J: ",j," T: ", t)
print("try again")
continue
else:
break
if flag==True:
print("Valid password")
in this code it does not print valid when the password entered is valid.