Build an RPG Character - Build an RPG Character

Tell us what’s happening:

18 and 19 of my code is marked x , please I need pointers to make it pass

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'
    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' 
    return f'{name} \nSTR full_dot * STR + empty_dot * (10 - STR)\nINT full_dot * INT + empty_dot * (10 - INT)\nCHA full_dot * CHA + empty_dot * (10 - CHA)'  
print(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

Hi @Iskenny

Your function needs to use the dots supplied in lines 1 and 2 of the editor.

Happy coding

Hi @Iskenny,

Your f-string is not embedding all of the expressions in curly braces. Also, where is STR defined as a variable in this bit of code? full_dot * STR

Use the function’s parameters.

Happy coding!

thanks, i have corrected that, the 18 has passed but the 19 is still marked X

Hi @Iskenny

19. When create_character is called with valid values it should output the character stats as required.

What happens if you input invalid values?

Happy coding

post your updated code please

this is it, and thanks
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'
    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 'ren\nSTR ●●●●○○○○○○\nINT ●●○○○○○○○○\nCHA ●○○○○○○○○○'
print(create_character('ren', 4, 2, 1))

I will leave a copy of my function in case someone else has a doubt:
removed by moderator

Hi @Iskenny

Do the following print calls look right?

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

Happy coding

Welcome to the forum @karim1221,

It is great that you solved the challenge, but instead of posting your full working solution, it is best to stay focused on answering the original poster’s question(s) and help guide them with hints and suggestions to solve their own issues with the challenge. How to Help Someone with Their Code Using the Socratic Method

We are trying to cut back on the number of spoiler solutions found on the forum and instead focus on helping other campers with their questions and definitely not posting full working solutions.

Happy coding