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

密码验证合格程序

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


def zhonglei(s):
    upp = 0
    low = 0
    num = 0
    other = 0

    for k, i in enumerate(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 num > 0 and other > 0) or (upp > 0 and low > 0 and num > 0) or (upp > 0 and low > 0 and num > 0 and other > 0):
            return True
    else:
        return False

def zichuan(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 zichuan(s):
            print('OK')
        else:
            print('NG')
    except:
        break


全部评论

相关推荐

11-18 16:08
福州大学 Java
影流之主:干10年不被裁,我就能拿别人一年的钱了,日子有盼头了
点赞 评论 收藏
分享
评论
点赞
收藏
分享
牛客网
牛客企业服务