Build an RPG Character - Build an RPG Character

Tell us what’s happening:

I cannot get 7 onwards. I have tried everything and I still can’t seem to get it right, if anyone would be kind enough to help. All help is appreciated!

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 len(name) > 10:
        return 'The character name is too long'
    if name == '':
        return 'The character should have a name'
    if name != ' ':
        return 'The character name should not contain spaces'
        stats = [strength, intelligence, charisma]
    if not all(isinstance(stat, int) for stat in stats):
        return 'All stats should be integers.'
    if any(stat < 1 for stat in stats):
        return 'All stats should be no less than 1'
    if any(stat > 4 for stat in stats):
        return 'All stats should be no more than 4'
    if sum(stats) != 7:
        return 'The character should start with 7 points'
    def dots(value):
        return value * full_dot + (10 - value) * empty_dot

    return(
        f"{name}\n"
        f"STR {dots(strength)}\n"
        f"INT {dots(intelligence)}\n"
        f"CHA {dots(charisma)}"
    )

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.2 Safari/605.1.15

Challenge Information:

Build an RPG Character - Build an RPG Character

For test 7: What did you try to investigate?

What’s the requirement and what’s the line of code to implement it?

I changed the whole bottom half of the code and it still shows 7. When create_character is called with a second, third or fourth argument that is not an integer it should return All stats should be integers.

What does your function return when you call it with a second, third or fourth argument that is not an integer?

It doesn’t return anything

full_dot = '●'
empty_dot = '○'

def create_character(name,strength,intelligence,charisma):
    if not isinstance(name, str):
        return "The character name should be a string"
    elif name == "":
        return "The character should have a name"
    elif len(name) > 10:
        return "The character name is too long"
    elif " " in name:
        return "The character name should not contain spaces"
    elif not all(isinstance (stat,int) for stat in(strength,intelligence,charisma)):
        return "All stats should be integers"
    elif strength < 1 or intelligence < 1 or charisma < 1:
        return "All stats should be no less than 1"
    elif strength > 4 or intelligence > 4 or charisma > 4: 
        return "All stats should be no more than 4"
    total = strength + intelligence + charisma
    if total != 7:
        return "The character should start with 7 points" 
    else:
        return (
        f"{name}\n"
        f"STR {full_dot * strength}{empty_dot *(10-strength)}\n"
        f"INT {full_dot * intelligence}{empty_dot *(10-intelligence)}\n"
        f"CHA {full_dot * charisma}{empty_dot *(10-charisma)}\n")

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


full_dot = '●'
empty_dot = '○'

def create_character(name,strength,intelligence,charisma):
    if not isinstance(name, str):
        return "The character name should be a string"
    elif name == "":
        return "The character should have a name"
    elif len(name) > 10:
        return "The character name is too long"
    elif " " in name:
        return "The character name should not contain spaces"
    elif not all(isinstance (stat,int) for stat in(strength,intelligence,charisma)):
        return "All stats should be integers"
    elif strength < 1 or intelligence < 1 or charisma < 1:
        return "All stats should be no less than 1"
    elif strength > 4 or intelligence > 4 or charisma > 4: 
        return "All stats should be no more than 4"
    total = strength + intelligence + charisma
    if total != 7:
        return "The character should start with 7 points" 
    else:
        return (
        f"{name}\n"
        f"STR {full_dot * strength}{empty_dot *(10-strength)}\n"
        f"INT {full_dot * intelligence}{empty_dot *(10-intelligence)}\n"
        f"CHA {full_dot * charisma}{empty_dot *(10-charisma)}\n")

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

I can’t get 11 and 12 can anyone help?

  1. create_character('ren', 4, 2, 1) should return ren\nSTR ●●●●○○○○○○\nINT ●●○○○○○○○○\nCHA ●○○○○○○○○○.

This is what you should be returning, including where all the newlines should be.

Not sure why you changed this from what you had originally.

Did you copy this from someone else?

I rewrote the whole thing because I couldn’t get the stat section to work. But no I didn’t copy.

1 Like

I fixed it, I just had to move the \n. Thanks for the help!

1 Like

If that was true, why did you rewrite the last part, honestly

Also why did you completely restructure the entire thing.

Does not make a lot of sense tbh

I did look for help and I looked up ways to fix it

hello i hope u r doing well

i have a problem in this case i mean in this lab can u help me!

Hello @narges01 , welcome to freeCodeCamp! :waving_hand:

If you have any trouble with the labs, you can click the button Ask for help at the bottom of the page ! Please be sure to check if the question hasn’t been already answered and follow the Read-Search-Ask method before creating a new post. Then, describe your problem and we’ll answer ASAP !

2 Likes