String Validators

  • + 0 comments
    from string import ascii_uppercase, digits,ascii_lowercase, punctuation
    from typing import Tuple
    
    def match_characters(input: str)->Tuple[bool,bool,bool,bool,bool]:
        hadalnum,hadalpha,haddigit,hadlower,hadsupper=False,False,False,False,False
        for s in input:
            if s in ascii_uppercase:
                hadsupper=True;
            elif s in ascii_lowercase:
                hadlower=True;
            elif s in digits:
                haddigit=True
            elif hadsupper and hadlower and haddigit:
                return True, True, True, True, True
            else:
                continue
        return True if (hadsupper or hadlower or haddigit) else False, True if (hadsupper or hadlower) else False, haddigit, hadlower, hadsupper
            
    
    if __name__ == '__main__':
        s = input()
        hadalnum,hadalpha,haddigit,hadlower,hadsupper=match_characters(s)
        print(hadalnum)
        print(hadalpha)
        print(haddigit)
        print(hadlower)
        print(hadsupper)