Build an RPG Character - Build an RPG Character

Tell us what’s happening:

I wrote the code and am getting the right results when I run it in python on my own computer. Correct results even if I change the inputs. Yet, tests 11 and 12 always fail.

Your code so far

full_dot = '●'
empty_dot = '○'

def create_character(name, strength,intelligence, charisma):
    stats = (strength, intelligence, charisma)
    stats_total_max = 7
    stats_ind_max = 4
    stats_ind_min = 1
    char_name_max_length = 10
    total_dots = 10
    if not isinstance(name, str):
        return 'The character name should be a string'

    if not name:
        return 'The character should have a name'
    
    if len(name) > char_name_max_length:
        return 'The character name is too long'
    if ' ' in name:
        return 'The character name should not contain spaces'
    for stat in stats:
        if not isinstance(stat,int):
            return 'All stats should be integers'
        
        elif stat < stats_ind_min:
            return 'All stats should be no less than 1'
    
        elif stat > stats_ind_max:
            return 'All stats should be no more than 4'
    
    if sum(stats) != stats_total_max:
        return 'The character should start with 7 points'

    def make_bar(value,num_dots=10):
        return full_dot * value + empty_dot * (num_dots - value)
    
    results = f"""{name}
    STR: {make_bar(strength,total_dots)}
    INT: {make_bar(intelligence,total_dots)}
    STR: {make_bar(charisma,total_dots)}"""
    return results

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36 Edg/143.0.0.0

Challenge Information:

Build an RPG Character - Build an RPG Character

Carefully check this line.

Thanks. That was definitely an error but even after I fix that, I am still not getting check marks on tests 11 and 12

you have an extra character in each of the stats line

Can you give me line numbers? I am comparing my code with the instructions and am not seeing what the extra character would be. I removed the colon from lines 39-41 with no success. Everything else returns the correct output

print(repr(create_character('ren', 4, 2, 1))) 
print(repr('ren\nSTR ●●●●○○○○○○\nINT ●●○○○○○○○○\nCHA ●○○○○○○○○○'))

Add this to the bottom of your file so you can compare actual to expected.

    print("sample: create_character('ren', 4, 2, 1)") #suggested lines to compare output
    print('sample: ren\nSTR ●●●●○○○○○○\nINT ●●○○○○○○○○\nCHA ●○○○○○○○○○') #suggested lines to compare output
    print(f"runs command: create_character('{name}',{strength},{intelligence},{charisma})") #to compare input
    print(f"{name}\nSTR {make_bar(strength,total_dots)}\nINT {make_bar(intelligence,total_dots)}\nCHA {make_bar(charisma,total_dots)}")
    print("looks successful")

create_character('ren',2,3,2)

Since I am confident that the rest of the script works as expected (all the tests show checks). I am including the last few lines. Including the lines that were recommended I add.
Here is a screenshot of the output I get. Looks like I am getting the output that is asked for.

Yes. It looks like you updated your code to make the change that was needed.

The tests beg to differ.
I still get this result

Please show the output from the two lines of code I asked you to run.

post your updated code please

full_dot = '●'
empty_dot = '○'

def create_character(name, strength,intelligence, charisma):
    stats = (strength, intelligence, charisma)
    stats_total_max = 7
    stats_ind_max = 4
    stats_ind_min = 1
    char_name_max_length = 10
    total_dots = 10
    if not isinstance(name, str):
        return 'The character name should be a string'

    if not name:
        return 'The character should have a name'
    
    if len(name) > char_name_max_length:
        return 'The character name is too long'
    if ' ' in name:
        return 'The character name should not contain spaces'
    for stat in stats:
        if not isinstance(stat,int):
            return 'All stats should be integers'
        
        elif stat < stats_ind_min:
            return 'All stats should be no less than 1'
    
        elif stat > stats_ind_max:
            return 'All stats should be no more than 4'
    
    if sum(stats) != stats_total_max:
        return 'The character should start with 7 points'

    def make_bar(value,num_dots=10):
        return full_dot * value + empty_dot * (num_dots - value)
    
    print(f"runs command: create_character('{name}',{strength},{intelligence},{charisma})") #to compare input
    print(f"{name}\nSTR {make_bar(strength,total_dots)}\nINT {make_bar(intelligence,total_dots)}\nCHA {make_bar(charisma,total_dots)}")


create_character('ren',2,3,2)

is the function always returning something?

yes. This is what the terminal shows. It also works when I run it on my own computer.

which line has that return statement?

What happened to this block of code from your original post? With corrections of course.

The print statements were just for testing…

sweet. That was it. Thank you

I removed them in favor of a single line. Though I probably could have done something like return results

This is what I replaced it with.
return f"{name}\nSTR {make_bar(strength,total_dots)}\nINT {make_bar(intelligence,total_dots)}\nCHA {make_bar(charisma,total_dots)}"