题解 | #密码验证合格程序#
密码验证合格程序
https://www.nowcoder.com/practice/184edec193864f0985ad2684fbc86841
def func(stri): if len(stri) <=8: return False a, b, c, d = 0, 0, 0, 0 for i in stri: if 'A'<=i<='Z': a = 1 # 满足一次条件值就为1 elif 'a'<=i<='z': b = 1 elif '0'<=i<='9': c = 1 elif i == '' or i == '\n': return False else: d = 1 if a + b + c + d < 3: # 小于三种不满足 return False for i in range(len(stri) - 3): # 当能被子串分割时,说明存在相同的子串 if len(stri.split(stri[i:i+3])) >= 3: return False return True try: while True: if func(input()): print('OK') else: print('NG') except EOFError: pass