Build an RPG character - Build an RPG Character

Tell us what’s happening:

everything works as needed, but still giving errors like:
2. When create_character is called with a first argument that is not a string it should return The character name should be a string.
3. When create_character is called with a first argument that is longer than 10 characters it should return The character name is too long.
and etc.

What’s wrong?

Your code so far

full_dot = '●'
empty_dot = '○'



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

    STRfull = ""
    STRem = ""

    INTfull = ""
    INTem = ""

    CHAfull = ""
    CHAem = ""
    
    #checking
    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 " " 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.')
    
    #if passed all
    for x in range(strength):
      STRfull = STRfull + full_dot
    for x in range(10-strength):
        STRem = STRem + empty_dot

    for x in range(intelligence):
      INTfull = INTfull + full_dot
    for x in range(10-intelligence):
        INTem = INTem + empty_dot

    for x in range(charisma):
      CHAfull = CHAfull + full_dot
    for x in range(10-charisma):
        CHAem = CHAem + empty_dot

    return (f'{name} \nSTR {STRfull}{STRem} \nINT {INTfull}{INTem} \nCHA {CHAfull}{CHAem}')

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

Your browser information:

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

Challenge Information:

Build an RPG character - Build an RPG Character

Hi @MrHampter and welcome to our community!

Your error messages shouldn’t end with a period (full stop). Fixing that issue will pass some of the failing tests.

As for other tests, ensure that you are precisely matching the required output and that your logic is also precise.

You can wrap the contents of your print call in repr() to compare your output with the expected output.

oke i fixed the text, but 9-10 stories still not marked as completed. (i know what doing dot-caharacteristic with extra variables is a dumb thing, but im trying my best ;_;). can you advise me any other solution of this problem?

Can you share your updated code please?

full_dot = ‘●’

empty_dot = ‘○’

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

STRfull = ""

STRem = ""



INTfull = ""

INTem = ""



CHAfull = ""

CHAem = ""



#checking

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 " " 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')



#if passed all

for x in range(strength):

  STRfull = STRfull + full_dot

for x in range(10-strength):

    STRem = STRem + empty_dot



for x in range(intelligence):

  INTfull = INTfull + full_dot

for x in range(10-intelligence):

    INTem = INTem + empty_dot



for x in range(charisma):

  CHAfull = CHAfull + full_dot

for x in range(10-charisma):

    CHAem = CHAem + empty_dot



return (f'{name} \\nSTR {STRfull}{STRem} \\nINT {INTfull}{INTem} \\nCHA {CHAfull}{CHAem}')

print(create_character(“ren”, 4, 2, 1))

here

If you wrap the contents of the print call with repr(), and compare it with the expected output, you should see the differences:

EXAMPLE:

print('my output:')
print(repr(create_character("ren", 4, 2, 1)))
print('expected output:')
print(repr('ren\nSTR ●●●●○○○○○○\nINT ●●○○○○○○○○\nCHA ●○○○○○○○○○'))

Untitled

so the problem is in second “\“?

don’t you also see extra spaces?

OH, ACTUALLY! thank u so much

1 Like