Python RPG Character Creator Solution (Using Dot Stats Matrix)

Hey everyone! I wanted to share a custom solution I built for a Python character creator project. It validates names and stats, then prints a clean visual stat bar using dots.

full_dot = '●'
empty_dot = '○'

def format_stat(label, value):
    return label + " " + full_dot * value + empty_dot * (10 - value)

def create_character(name, strength, intelligence, charisma):
    stats = (strength, intelligence, charisma)

    # Character name validation
    if not isinstance(name, str): return "The character name should be a string"
    if len(name) == 0: return "The character should have a name"
    if len(name) > 10: return "The character name is too long"
    if " " in name: return "The character name should not contain spaces"
    
    # Stats validation
    if not all(type(stat) is int for stat in stats):
        return "All stats should be integers"
    if any(stat < 1 for stat in stats):
        return "All stats should be no less than 1"
    if any(stat > 4 for stat in stats):
        return "All stats should be no more than 4"
    if sum(stats) != 7:
        return "The character should start with 7 points"
    
    # Output 
    str_line = format_stat("STR", strength)
    int_line = format_stat("INT", intelligence)
    cha_line = format_stat("CHA", charisma)

    return "\n".join([name, str_line, int_line, cha_line])

I’d love to hear your feedback on how I handled the conditional validation checks!

One edge case: checking only for " " means a tab or newline can still pass as the name. Consider using if not name.strip() to catch an empty or whitespace-only name, followed by if any(ch.isspace() for ch in name) to reject all embedded whitespace consistently.

that is not something we teach in the first module, so it’s not necessary at this point

but those are good suggestions for the real world