Build an RPG character

Tell us what’s happening:

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’

elif name.find(’ ') != -1:

return ‘The character name should not contain spaces’

if not (isinstance (strength, int) or isinstance (intelligence, int) or isinstance (charisma, int)):

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’

elif (strength+intelligence+charisma != 7):

return ‘The character should start with 7 points’

STR = (full_dot*strength)+empty_dot*(10-strength)

return f"{name}\n STR {STR} \n INT {STR} \n CHA {STR}"

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


It keeps spitting out an error for line 8 saying that it is outside of the function. I have tried everything I can think of so far to fix this by indenting, back spacing that indentation etc. How do I fix this?

Welcome to the forum @themattyo191

If you have a question about a specific challenge as it relates to your written code for that challenge and need some help, click the Help button located on the challenge.

The Help button will create a new topic with all code you have written and include a link to the challenge also. You will still be able to ask any questions in the post before submitting it to the forum.

Happy coding

Hi @themattyo191,

We can’t troubleshoot your code unless it’s formatted, especially since indentation is so important in Python.

You can either create a new topic using the “Help” button as Teller suggested or you can post your formatted code 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:

Thank you