题解 | #密码验证合格程序#
密码验证合格程序
https://www.nowcoder.com/practice/184edec193864f0985ad2684fbc86841
while True: try: st=input() if len(st)<8: print('NG') continue ad = 0 NG=False lowercase=False uppercase=False number=False special=False for i in range(len(st)): #print(st[i],lowercase,uppercase,number,special) if st[i]>='a' and st[i]<='z': if not lowercase: ad+=1 lowercase=True elif st[i]>='A' and st[i]<='Z': if not uppercase: uppercase=True ad+=1 elif st[i]>='0' and st[i]<='9' : if not number: number=True ad+=1 elif not special: special = True ad+=1 if ad < 3: print('NG') NG = True continue for i in range(len(st)-3): for j in range(i+3, i+len(st)-i//2+1): if st[i:j] in st[j+2:len(st)]: print('NG') #print (st[i:j]) NG = True break if NG==True: break if NG==False: print('OK') except: break