Xiaoming works in the card center, and many system accounts used require a security password. A password can be called a secure password if it meets the following specifications:
1. The password contains at least 6 characters and at most 20 characters;
2. It contains at least one lowercase letter, at least one uppercase letter, and at least one number;
1. The password contains at least 6 characters and at most 20 characters;
2. It contains at least one lowercase letter, at least one uppercase letter, and at least one number;
3. There cannot be 3 consecutive identical letters.
Please write a function that checks if a password is a secure password.
The input is a string as the password, and the output is the minimum number of changes to make this password secure. Returns 0 if it is already a secure password.
Note: Inserting, deleting, or replacing a character is regarded as a change.
Just finished the code for the first step: check if the password is secure
s=input("please input your passwords:") flag_upper=flag_little=flag_num=others=0 if len(s)<6 or len(s)>20: print("passwords is too short!") else: for j in range(len(s)-3): if type(s[j])==type(s[j+1]) and type(s[j])==type(s[i+2]): if s[j]==s[j+1] and s[j]==s[j+2]: print("can't use the same three word") else: pass else: pass for i in s: if ord(i)>=97 and ord(i)<=122: flag_little+=1 elif ord(i)>=65 and ord(i)<=90: flag_upper+=1 elif ord(i)>=48 and ord(i)<=57: flag_num+=1 else: others+=1 if flag_upper>0 and flag_little>0 and flag_num>0: print("successful") else: print("passwords is invalid")