题解 | #密码验证合格程序#
密码验证合格程序
http://www.nowcoder.com/practice/184edec193864f0985ad2684fbc86841
这里注意判断大小写是isupper、islower、isdigit 以及循环 while True: try: s = input() except: break
def get_result(code):
if len(code)<8:
return "NG"
up = 0
low = 0
di = 0
other = 0
for i in code:
if i.isupper():
up = 1
elif i.islower():
low = 1
elif i.isdigit():
di = 1
else:
other = 1
if up+low+di+other<3:
return "NG"
re = []
for i in range(3, len(code)):
split = code[i-3:i]
if split in re:
return "NG"
else:
re.append(split)
return "OK"
while True:
try:
code = input()
code = str(code)
result = get_result(code)
print(result)
except:
break
查看17道真题和解析