Build an RPG Character

May you please help with this one: The last step is failing “When create_character is called with valid values it should output the character stats as required.” Here is my code.

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 len(character_name) ==0:

        return 'The character should have a name'

    

    if len(character_name) > 10:

        return 'The character name is too long'

    

    if not isinstance(strength,int):

        return 'All stats should be integers'

    

    if not isinstance(intelligence,int):

        return 'All stats should be integers'

    

    if not isinstance(charisma,int):

        return 'All stats should be integers'

    

    if ' ' in character_name:

        return 'The character name should not contain spaces'

    

    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 not strength + intelligence + charisma ==7:

        return 'The character should start with 7 points'

    else :

        strenth_empty= empty_dot \* (10 - strength)

        intelligence_empty= empty_dot \* (10 - intelligence)

        charisma_empty= empty_dot \* (10 - charisma)

        return f'{character_name}\\nSTR {full_dot\*strength}{strenth_empty}\\nINT {full_dot\*intelligence}{intelligence_empty}\\nCHA {full_dot}{charisma_empty}'



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

I’ve edited your post to improve the readability of the code. When you enter a code block into a forum post, please precede it with three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add the backticks.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').

if you check with print(create_character('Bob', 1, 2, 4)), does the output look correct to you?

Thanks for the input. Let me have a look because it is giving an incorrect value

Thanks for your input the issue has been resolved

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.