Build an RPG Character - Build an RPG Character

Tell us what’s happening:

I am not able to get past steps #18 and #19.
I genuinely do not know what the mistake is in my code

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"
    elif character_name == "":
        return "The character should have a name"
    elif len(character_name) > 10 :
        return "The character name is too long"
    elif " " in character_name :
        return "The character name should not contain spaces"
    elif any(not isinstance(stat,int) for stat in [strength,intelligence,charisma]) :
        return "All stats should be integers"
    elif any(stat <1 for stat in [strength,intelligence,charisma]) :
        return "All stats should be no less than 1"
    elif any(stat >4 for stat in [strength,intelligence,charisma]) :
        return "All stats should be no more than 4"
    elif strength+intelligence+charisma != 7 :
        return "The character should start with 7 points"
    else :
        stats = {"STR":strength,"INT":intelligence,"CHA":charisma}
        result= f"{character_name}\n"
        for abbr, value in stats.items() :
            full_dots= full_dot*value
            empty_dots = empty_dot*(10-value)
            result += f"{abbr} {full_dots}{empty_dots}\n"
        return result
create_character('ren', 4, 2, 1) 

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) 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

Welcome to the forum @abhiramibh09,

Try testing like this so you can see what your function returns, including newlines: print(repr(create_character('ren', 4, 2, 1)))

Happy coding

ren\nSTR ●●●●○○○○○○\nINT ●●○○○○○○○○\nCHA ●○○○○○○○○○
this is what its returning in the ouput. But the error messages still do not disappear

Did you update your code? That is not what I see in the console with the code you posted.

uhh how do i update the code i dont know

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"

elif character_name == "":

    return "The character should have a name"

elif len(character_name) > 10 :

    return "The character name is too long"

elif " " in character_name :

    return "The character name should not contain spaces"

elif any(not isinstance(stat,int) for stat in \[strength,intelligence,charisma\]) :

    return "All stats should be integers"

elif any(stat <1 for stat in \[strength,intelligence,charisma\]) :

    return "All stats should be no less than 1"

elif any(stat >4 for stat in \[strength,intelligence,charisma\]) :

    return "All stats should be no more than 4"

elif strength+intelligence+charisma != 7 :

    return "The character should start with 7 points"

else :

    stats = {"STR":strength,"INT":intelligence,"CHA":charisma}

    result= f"{character_name}\\n"

    for abbr, value in stats.items() :

        full_dots= full_dot\*value

        empty_dots = empty_dot\*(10-value)

        result += f"{abbr} {full_dots}{empty_dots}\\n"

    return result

create_character(‘ren’, 4, 2, 1)

print(repr(create_character(‘ren’, 4, 2, 1)))

this is what it is currently if its ok to post like this

It doesn’t look like you have changed anything in your code and I see this in the console:
'ren\nSTR ●●●●○○○○○○\nINT ●●○○○○○○○○\nCHA ●○○○○○○○○○\n' from print(repr(create_character(‘ren’, 4, 2, 1))). Notice the extra newline character at the end.

fixed it! thank you so much