Build an RPG character

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’

    final_character = f'{name}'
    f'STR,{strength * full_dot + empty_dot * (10 - strength)}'
    f'INT,{intelligence * full_dot  + empty_dot * (10 - intelligence)}'
    f'CHA,{charisma * full_dot + empty_dot *  (10 - charisma)}'
    print(final_character)

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


Build an RPG Character: Build an RPG Character | freeCodeCamp.org

I do NOT understand why my code isn’t working. I have tried so many different ways to make this work. I have been all over this site regarding this particular lab to try and figure it out from other people and I can’t get it to work. 18 and 19 refuse to run for me.

I understand the method people are going about on here when it comes to not giving the answer straight away and trying to teach, but none of that has helped me when looking through. Can someone please give me some sort of direction that will actually help me through this?

Welcome to the forum @devbone,

Please re-post your code formatted as follows:

There are two ways you can format your code to make it easier to read and test:

  1. After you copy/paste your code into the editor, select it by dragging your cursor over it then click the (</>) button in the toolbar to automatically wrap your code in backticks. (You can click on the animated demo image below to enlarge it.)

  1. Manually add three backticks on a new line above your code and on a new line after your code. Note that a backtick is NOT the same as a single quote('). To find the backtick key on your keyboard, see this post.

To see changes to your post as you make them, you can click the (M+) button on the toolbar to bring up the rich text editor:

Are you asked to print the final string or return it?

Wrap your function call in print() to see what your function returns in the console.


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'

final_character = f'{name}'
f'STR,{strength * full_dot + empty_dot * (10 - strength)}'
f'INT,{intelligence * full_dot + empty_dot * (10 - intelligence)}'
f'CHA,{charisma * full_dot + empty_dot *  (10 - charisma)}'
return(final_character)

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

This is the updated code. It only prints ren for me in the console. The tips didn’t help me either. Can anyone give me the answer for this?

Hi @devbone,

You are not honoring Python’s strict indentation rules.

All of the code inside the function should be indented.

The code inside each if statement should be indented.

What tips didn’t help you? Have you tried Socrates?

Our focus is on guiding you to debug the code yourself, not to hand you a solution. Sorry.

Happy coding

I tried Socrates and wasn’t able to discern what it was trying to make me do. What about my code is wrong? I don’t see what the issue with it is

indentation, the content of the function can’t be indented equal to the function

this could be an issue with how you are posting your code maybe? please be careful if so, we need to see your code as accurately as possible

I figured it out by using Socrates and looking at other people’s responses.