题解 | #密码验证合格程序#

密码验证合格程序

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
全部评论

相关推荐

酷酷的喜马拉雅山:感觉这比一直在初筛不动的好多了
点赞 评论 收藏
分享
10-03 17:08
已编辑
西安电子科技大学 Java
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务