String Validators

Sort by

recency

|

1928 Discussions

|

  • + 0 comments

    if name == 'main': def get_attribute(string,attribute): count = 0 for i in string: if getattr(i,attribute)() is True: count +=1 if count>0: print(True) else: print(False)

    string_list = list(input())
    get_attribute(string_list,'isalnum')
    get_attribute(string_list,'isalpha')
    get_attribute(string_list,'isdigit')
    get_attribute(string_list,'islower')
    get_attribute(string_list,'isupper')
    
  • + 0 comments

    My solution:

    if __name__ == '__main__':
        s = input()
        
        true_false = []
        
        true_false.append(any(c.isalnum() for c in s))
        true_false.append(any(c.isalpha() for c in s))
        true_false.append(any(c.isdigit() for c in s))
        true_false.append(any(c.islower() for c in s))
        true_false.append(any(c.isupper() for c in s))
        
        for result in true_false:
            print(result)
    
  • + 0 comments

    if name == 'main':

    using all() or any()

    s = input()
    print(all(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))
    
  • + 0 comments

    Here is a simple solution to this problem

    if name == 'main': s = input() alphanum = False alphabetical = False number = False lowercase = False Uppercase = False

    for i in s:
        if alphanum == False:
            if(i.isalnum()):
                alphanum = True
    
        if alphabetical == False:
            if(i.isalpha()):
                alphabetical = True
    
        if number == False:
            if(i.isdigit()):
                number = True
    
        if lowercase == False:
            if(i.islower()):
                lowercase = True
    
        if Uppercase == False:
            if(i.isupper()):
                Uppercase = True
    
    print(f"{alphanum}\n{alphabetical}\n{number}\n{lowercase}\n{Uppercase}")
    
  • + 0 comments

    if name == 'main': s = input() alphanum = False alphabetical = False number = False lowercase = False Uppercase = False

    for i in s:
        if alphanum == False:
            if(i.isalnum()):
                alphanum = True
    
        if alphabetical == False:
            if(i.isalpha()):
                alphabetical = True
    
        if number == False:
            if(i.isdigit()):
                number = True
    
        if lowercase == False:
            if(i.islower()):
                lowercase = True
    
        if Uppercase == False:
            if(i.isupper()):
                Uppercase = True
    
    print(f"{alphanum}\n{alphabetical}\n{number}\n{lowercase}\n{Uppercase}")