String Validators

  • + 1 comment

    Or just:

    checks = ['isalnum', 'isalpha', 'isdigit', 'islower', 'isupper']
    results = [False for _ in range(len(checks))]
    to_check = checks[:]
    
    for char in input().strip():
        if not to_check:
            break
    
        for check in to_check:
            if getattr(char, check)():
                results[checks.index(check)] = True
                to_check.remove(check)
    
    print(*results, sep='\n')