Build an RPG Character - Build an RPG Character

Tell us what’s happening:

When pressing Check Your Code, I get "create_character(‘ren’, 4, 2, 1) should return ren\nSTR ●●●●○○○○○○\nINT ●●○○○○○○○○\nCHA ●○○○○○○○○○ which is what I am getting in terminal. Bit confused.

Your code so far

full_dot = '●'
empty_dot = '○'
def create_character(name,strength,intelligence,charisma):
    if not isinstance(name,str):
        return('The character name should be a string')
    if name=="":
        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')
    for stat in (strength,intelligence,charisma):
        if not isinstance(stat,int):
            return('All stats should be integers')
        if stat<1:
            return('All stats should be no less than 1')
        if stat>4:
            return('All stats should be no more than 4')
    if (strength+intelligence+charisma)!=7:
            return('The character should start with 7 points')

    def stat_bar(value):
        return full_dot * value + empty_dot * (10-value)
    return f"{name}\\nSTR {stat_bar(strength)}\\nINT {stat_bar(intelligence)}\\nCHA {stat_bar(charisma)}"

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

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.4 Safari/605.1.15

Challenge Information:

Build an RPG Character - Build an RPG Character

All good. Sorted. As a newbie, I read the \ in the expected return and placed too many of them into stat_bar return command.

If you are reading this and this didn’t help you solve it, it might be because, just like me, you were using triple quotation marks to do the multiple line string part. It works just as good but they want you to use “\n” at the beginning of each line instead.