String Validators

Sort by

recency

|

1848 Discussions

|

  • + 0 comments
    if __name__ == '__main__':
        s = input()
    
        check_validation = {"Check isalnum": lambda s: s.isalnum(),
                            "Check isalpha": lambda s: s.isalpha(),
                            "Check isdigit": lambda s: s.isdigit(),
                            "Check islower": lambda s: s.islower(),
                            "Check isupper": lambda s: s.isupper()}
    
        check = [any([check_validation[check](character) for character in s]) for check in check_validation]
        for i in check:
            print(i)
    
  • + 0 comments

    Here is my completely overengineered Solution for you:

    import re

    if name == 'main': s = input() m = re.search(r'(?=(.\w)?)(?=(.[A-Za-z])?)(?=(.\d)?)(?=(.[a-z])?)(?=(.*[A-Z])?)', s) print('\n'.join([str(bool(group)) for group in m.groups()]))

  • + 0 comments
    if __name__ == '__main__':
        s = input()
        a = False
        b = False
        c = False
        d = False
        e = False
        for i in s:
            if i.isalnum():
                a = True
            if i.isalpha():
                b = True
            if i.isdigit():
                c = True
            if i.islower():
                d = True
            if i.isupper():
                e = True
        print(a,b,c,d,e, sep='\n')
            
    
  • + 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)
    
  • + 0 comments

    if name == 'main': s = input() print(any(c.isalnum() for c in s)) print(any(c.isalpha() for c in s)) print(any(c.isdigit() for c in s)) print(any(c.islower() for c in s)) print(any(c.isupper() for c in s))