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

密码验证合格程序

https://www.nowcoder.com/practice/184edec193864f0985ad2684fbc86841

def zhonglei(s):
    upp = 0
    low = 0
    num = 0
    other = 0
    for i in s:
        if i.isupper():
            upp += 1
        elif i.islower():
            low += 1
        elif i.isdigit():
            num += 1
        else:
            other += 1
    if (
        (upp > 0 and low > 0 and num > 0)
        or (upp > 0 and low > 0 and other > 0)
        or (low > 0 and other > 0 and num > 0)
        or (upp > 0 and other > 0 and num > 0)
        or (upp > 0 and low > 0 and other > 0 and num > 0)
    ):
        return True
    return False


def chongfu(s):
    for i in range(len(s)):
        if s[i : i + 3] in s[i + 3 :]:
            return False
    return True


while True:
    try:
        s = input()
        if len(s) >= 8 and zhonglei(s) and chongfu(s):
            print("OK")
        else:
            print("NG")

    except:
        break

全部评论

相关推荐

我见java多妩媚:大外包
点赞 评论 收藏
分享
像好涩一样好学:这公司我也拿过 基本明确周六加班 工资还凑活 另外下次镜头往上点儿
点赞 评论 收藏
分享
评论
点赞
收藏
分享
牛客网
牛客企业服务