Strong Password

  • + 0 comments

    import string

    def minimumNumber(n, password):

    d = {'L': 0, 'U': 0, 'N': 0, 'S': 0}
    l, u, t, s = 1, 1, 1, 1
    for i in password:
        if i in string.ascii_lowercase:
            d['L'] = l
            l += 1
        if i in string.ascii_uppercase:
            d['U'] = u
            u += 1
        if i in string.digits:
            d['N'] = t
            t += 1
        if i in string.punctuation:
            d['S'] = s
            s += 1
    chars = len([v for k, v in d.items() if v == 0])
    if (n + chars) < 6:
        return 6 - n
    else:
        return chars