Build an RPG Character - Build an RPG Character

Tell us what’s happening:

Can someone help me? It appears I am at a standpoint. I answer one part of the requirements and another part becomes bad. For example number 2 and 3 of the requirements appear to be opposites sides of the same coin but if I answer number two number three is now wrong and if I answer number 3 than number 2 will be wrong. Those are not the only ones that are doing that. Almost every other requirement is wrong on my checklist. Can anybody help me please?

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.' #output name should be a string    
    if len(name) > 10:
        return 'The character name is too long.' #output name is too long
    if '' in name:
        return 'The character name should not contain spaces.'#output no spaces
    stat= {'STR': Strength, 'INT': Intelligence, 'CHA': Charisma} 
    for stat in stats.value():
        if not isinstance (stat, int):
            return('All stats should be integers.') #output need stats
    for stat in stats.value():
        if stat < 1:
            return ('All stats should be no less than 1.')#output Stats 1 or more
    for stat in stats.value():
        if stat > 4:
            return 'All stats should be no more than 4.' #output No more than 4
    if sum(stats.value()) != 7:
        return 'The character should start with 7 points.'


print(create_character)

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/152.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

Welcome to the forum @Awesome920

To help you debug, use the following print call.

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

It looks like the output contains an unwanted period at the end of the sentence.

Happy coding

is this really checking for a space?

It appears to be working in the outcome area where the code “prints”

I am still not sure. I inputed that and it is helping but still not 100% sure of what i am doing

Please share your updated code and a screen grab of 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.' #output name should be a string    

if len(name) > 10:

    return 'The character name is too long.' #output name is too long

if '' in name:

    return 'The character name should not contain spaces.'#output no spaces

stat= {'STR': Strength, 'INT': Intelligence, 'CHA': Charisma} 

for stat in stats.value():

    if not isinstance (stat, int):

        return('All stats should be integers.') #output need stats

for stat in stats.value():

    if stat < 1:

        return ('All stats should be no less than 1.')#output Stats 1 or more

for stat in stats.value():

    if stat > 4:

        return 'All stats should be no more than 4.' #output No more than 4

if sum(stats.value()) != 7:

    return 'The character should start with 7 points.'

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

Hi @Awesome920

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:

Happy coding

Hi @Awesome920

Here is the console output:

The character name should not contain spaces.

Check which if statement this comes from.

Happy coding

The return comes from the if statement. is that not correct?

so why do you get that when it does not contain spaces?

Ohhhh. I was looking at what I was meaning and not what the code was actually saying. My apologies