Build an RPG Character - Build an RPG Character

Tell us what’s happening:

def create_character(name, strength, intelligence, charisma):
.
.
.
.
if not (isinstance (strength, int) and isinstance (intelligence, int) and isinstance(charisma, int)):
return ‘All stats should be integers’

I am stuck on step 7 and cannot get past it, which tells me to return this message if the second, third, or fourth argument is not an integer. Can someone help me understand why I am stuck here or what I should do? It could potentially help me with step 8, too

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 len(name) > 10:
        return 'The character name is too long'
    if len(name) == 0:
        return 'The character should have a name'
    if name.find(' ') < len(name):
        return 'The character name should not contain spaces'
    if not (isinstance (strength, int) and (intelligence, int) and isinstance(charisma, int)):
            return 'All stats should be integers'

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36

Challenge Information:

Build an RPG Character - Build an RPG Character

What does your function return when you call it with that input? You need to call it and test it.

Ok i fixed it. Basically had to change the condition for having a space in name

The updated code for that is “if ‘ ‘ in name: return ‘The character name should not contain spaces‘”

However, I am not sure what step 12 is asking. “print (create_character(‘John’, 3, 3, 1))“ This gives me the correct output but does not help what is wrong.

Should I make changes to this condition:

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

    return 'The character should start with 7 points'

I tried changing the condition to if the sum < 7 but it fails with the condition if it is not equal to 7 (step 10)

test 12 is checking the same thing as test 11 but with different inputs

what is your updated code?

def create_character(name, strength, intelligence, charisma):

    if not(isinstance(name, str)):

        return 'The character name should be a string'

    if len(name) > 10:

        return 'The character name is too long'

    if len(name) == 0:

        return 'The character should have a name'

    if ' ' in name:

        return 'The character name should not contain spaces'

    if not (isinstance (strength, int) and isinstance (intelligence, int) and 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 ' + full_dot \* strength + empty_dot \* (10-strength) + '\\nINT ' + full_dot \* intelligence + empty_dot \* (10-intelligence) + '\\nCHA ' + full_dot \* charisma + empty_dot \* (10-charisma))



print (create_character('John', 3, 3, 1))

This is my updated code so far

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 (').

Can you repaste your code and make sure to format it? Not able to test this.

///codes are here

def create_character(name, strength, intelligence, charisma):
    if not(isinstance(name, str)):
        return 'The character name should be a string'
    if len(name) > 10:
        return 'The character name is too long'
    if len(name) == 0:
        return 'The character should have a name'
    if ' ' in name:
        return 'The character name should not contain spaces'
    if not (isinstance (strength, int) and isinstance (intelligence, int) and 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 ' + full_dot * strength + empty_dot * (10-strength) + '\nINT ' + full_dot * intelligence + empty_dot * (10-intelligence) + '\nCHA ' + full_dot * charisma + empty_dot * (10-charisma))

print (create_character('John', 3, 3, 1))

I have tried to do that here and this is the best my laptop is allowing (or on my browser for now). Can you let me know how should I change my condition for sum of stats to be >= 7? I tried to do < 7 as the condition but it seems to reject it for some reason

actually i figured out the problem - very silly error. just changed ‘ren\nSTR’ to ‘\nSTR’

1 Like

Is your code passing now? If you need further help, please post your updated code formatted as asked. Thank you.