Build an RPG Character Steps 18 & 19

Tell us what’s happening:

My code prints everything correctly–checked by using print(create_character, (‘ren’'4, 2, 1))–but I’m stuck on steps 18 and 19.

Your code so far

full_dot = '●'
empty_dot = '○'

def create_character(character_name,strength,intelligence,charisma):
    if not isinstance(character_name,str):
        return "The character name should be a string"
    if character_name=="":
        return "The character should have a name"
    if len(character_name)>10:
        return "The character name is too long"
    if " " in character_name:
        return "The character name should not contain spaces"

    if not isinstance(strength,int) or not isinstance(intelligence,int) or not isinstance(charisma,int):
        return "All stats should be integers"
    if strength <1 or intelligence <1 or charisma <1:
        return "All stats should be no less than 1"
    if strength >4 or intelligence >4 or charisma >4:
        return "All stats should be no more than 4"
    if strength+intelligence+charisma!=7:
        return "The character should start with 7 points"
    else:
        return character_name +"\n"+ 'STR'+full_dot*strength+empty_dot*(10-strength)+"\n"+'INT'+full_dot*intelligence+empty_dot*(10-intelligence) + "\n" + 'CHA'+full_dot*charisma+empty_dot*(10-charisma)

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

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

Your browser information:

User Agent is: Mozilla/5.0 (X11; CrOS x86_64 14541.0.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36

Challenge Information:

Build an RPG Character - Build an RPG Character

GitHub Link: freeCodeCamp/curriculum/challenges/english/blocks/lab-rpg-character/67d83df6f82eda3868dd2a84.md at main · freeCodeCamp/freeCodeCamp · GitHub

Hi @megane0724,

Try testing like this:

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

Happy coding

Hi @megane0724, building on what @dhess suggested with repr() — that’s exactly the trick to catch this one.

When you run those two prints, look very carefully at the very start of each stat line. Compare your STR line against the expected STR line character by character — there’s something sitting right between the stat label and the first dot in the expected output that your code isn’t adding.

Take a look at how you build each line: 'STR' + full_dot*strength + .... Is there anything missing between 'STR' and the dots? The repr() output will make it jump out.

Once you spot it for STR, the same fix applies to INT and CHA. You’re really close!

Hi! Your logic looks very close. I think the issue may be the exact formatting of the returned string.

Check the spacing after STR, INT, and CHA. The expected output likely needs a space between the label and the dots, like this:

STR ●●●●○○○○○○

But your current code returns it without that space:

STR●●●●○○○○○○

The tests compare the output exactly, so a missing space can cause the last steps to fail.

Hope this helps!

Ah omg you guys are so right, I was missing the space! Thank you :slight_smile: it was driving me mad hahaha