# Python RPG Character Creator Solution (Using Dot Stats Matrix)

**URL:** <https://forum.freecodecamp.org/t/python-rpg-character-creator-solution-using-dot-stats-matrix/802323>\
**Category:** I Built This\
**Tags:** python\
**Created:** [October 16, 2026, 2:41am UTC](https://forum.freecodecamp.org/t/python-rpg-character-creator-solution-using-dot-stats-matrix/802323 "2026-10-16T02:41:12Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![anjaneyulunarsingoju](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/anjaneyulunarsingoju/32/382052_2.png) [@anjaneyulunarsingoju](https://forum.freecodecamp.org/u/anjaneyulunarsingoju)\
**Post date:** [October 16, 2026, 2:41am UTC](https://forum.freecodecamp.org/t/python-rpg-character-creator-solution-using-dot-stats-matrix/802323/1 "2026-10-16T02:41:12Z")

</div>

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.

```python
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!

---

<div class="post-metadata">

**Author:** ![aikotanaka85](https://avatars.discourse-cdn.com/v4/letter/a/b77776/32.png) [@aikotanaka85](https://forum.freecodecamp.org/u/aikotanaka85)\
**Post date:** [October 16, 2026, 11:14am UTC](https://forum.freecodecamp.org/t/python-rpg-character-creator-solution-using-dot-stats-matrix/802323/2 "2026-10-16T11:14:53Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [October 16, 2026, 11:54am UTC](https://forum.freecodecamp.org/t/python-rpg-character-creator-solution-using-dot-stats-matrix/802323/3 "2026-10-16T11:54:58Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/freecodecamp/original/3X/e/1/e1c433102e34b46dfaa3e15d13ab9a514b127078.svg) [@system](https://forum.freecodecamp.org/u/system)\
**Post date:** [November 13, 2026, 11:55am UTC](https://forum.freecodecamp.org/t/python-rpg-character-creator-solution-using-dot-stats-matrix/802323/4 "2026-11-13T11:55:32Z")

</div>

Closed on November 13, 2026, 11:55am UTC

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
