Build an RPG character - Build an RPG Character

Tell us what’s happening:

test no. 5 is always wrong, is there something wrong in my code?

Your code so far

full_dot = '●'
empty_dot = '○'

def create_character(n, s, i, c):
    # Check name first
    if not isinstance(n, str):
        return 'The character name should be a string'
    
    if len(n) > 10:
        return 'The character name is too long'
    
    if ' ' in n:
        return 'The character name should not contain spaces'
    
    # Check if stats are valid integers
    # First, convert everything to string for consistent checking
    for stat_value in [s, i, c]:
        try:
            # Try to convert to int regardless of original type
            int(stat_value)
        except (ValueError, TypeError):
            return 'All stats should be integers'
    
    # Now safely convert them to integers
    s = int(s)
    i = int(i)
    c = int(c)
    
    # Check ranges
    if s < 1 or i < 1 or c < 1:
        return 'All stats should be no less than 1'
    
    if s > 4 or i > 4 or c > 4:
        return 'All stats should be no more than 4'
    
    total = s + i + c
    if total != 7:
        return 'The character should start with 7 points'
    
    # Calculate dots
    rs = 10 - s
    ri = 10 - i
    rc = 10 - c
    
    return f'''{n}
STR {s * full_dot}{rs * empty_dot}
INT {i * full_dot}{ri * empty_dot}
CHA {c * full_dot}{rc * empty_dot}'''

create_character("ren", 4, 2, 1)

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:145.0) Gecko/20100101 Firefox/145.0

Challenge Information:

Build an RPG character - Build an RPG Character

Consider whether trying to convert variable to integer proves that the initial data type was integer.

how to do that? I tried the int(charisma) but not right?

Try this test case

print(create_character("ren", "4", 2, 1))

You have in code check if variable has str data type. How that could be adapted to check if variable is an integer?

i did this and it worked…
removed by moderator

Don’t post solution code here please

It is great that you solved the challenge, but instead of posting your full working solution, it is best to stay focused on answering the original poster’s question(s) and help guide them with hints and suggestions to solve their own issues with the challenge. How to Help Someone with Their Code Using the Socratic Method

We are trying to cut back on the number of spoiler solutions found on the forum and instead focus on helping other campers with their questions and definitely not posting full working solutions.