思路:排除法
def check(s): "判断是否成立" # 1.长度不超过8则不成立 if len(s) <= 8: return "NG" # 2.存在有一个3位子串重复则不成立 for i in range(len(s) - 3): if s.count(s[i:i + 3]) > 1: return "NG" # 3.字符串中大、小写字母.数字.其它符号,少于3种则不成立 l = [0, 0, 0, 0] for i in s: if i.isupper(): l[0] = 1 elif i.islower(): l[1] = 1 elif i.isdigit(): l[2] = 1 else: l[3] = 1 if sum(l) < 3: return "NG" # 除出不成立的之后都成立 return "OK" while True: try: s = input() print(check(s)) except: break