Build an RPG Character - Build an RPG Character

Tell us what’s happening:

Please help I can’t get past problem 19. I don’t know whether the problem is my understanding or the program itself. I just want to finish it so I can move on

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'
    elif name == "":
        return 'The character should have a name'
    elif len(name) > 10 :
        return 'The character name is too long'
    elif ' 'in name:
        return 'The character name should not contain spaces'
    if not isinstance(strength,int) :
        return "All stats should be integers"
    if not isinstance(intelligence,int) :
        return "All stats should be integers"
    if not isinstance(charisma,int) :
        return "All stats should be integers"
    if strength < 1:
        return "All stats should be no less than 1"
    if intelligence < 1:
        return "All stats should be no less than 1"
    if charisma < 1:
        return "All stats should be no less than 1"
    if strength > 4:
        return "All stats should be no more than 4"
    if intelligence > 4:
        return "All stats should be no more than 4"
    if charisma > 4:
        return "All stats should be no more than 4"
    if (strength + intelligence+ charisma) != 7:
        return'The character should start with 7 points'
    stats = (name,strength,intelligence,charisma )
    return 'ren\nSTR ●●●●○○○○○○\nINT ●●○○○○○○○○\nCHA ●○○○○○○○○○'

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/143.0.0.0 Safari/537.36 OPR/127.0.0.0 (Edition ms_store)

Challenge Information:

Build an RPG Character - Build an RPG Character

You need to use the name and stats you received as input to build the output, not write them directly into the return line.

what if I call create_character('bob", 1, 3, 3)? test with print, what does your function return?

18. create_character('ren', 4, 2, 1) should return ren\nSTR ●●●●○○○○○○\nINT ●●○○○○○○○○\nCHA ●○○○○○○○○○.

Hard coding it in is the requirement for passing no.18. But now I can’t get problem 19 to work

Test #18 is just saying that when you call the function with the specific arguments given, your code should return that specific string.

But you should be able to call the function with different arguments and the string returned should adapt based on those arguments.

When you hard-code the return, your function always returns the same thing no matter what is passed to it in a function call.

full_dot = '●'
empty_dot = '○'

def create_character(name,strength, intelligence, charisma):
    if not isinstance(name, str):
        return 'The character name should be a string'
    elif name == "":
        return 'The character should have a name'
    elif len(name) > 10 :
        return 'The character name is too long'
    elif ' 'in name:
        return 'The character name should not contain spaces'
    if not isinstance(strength,int) :
        return "All stats should be integers"
    if not isinstance(intelligence,int) :
        return "All stats should be integers"
    if not isinstance(charisma,int) :
        return "All stats should be integers"
    if strength < 1:
        return "All stats should be no less than 1"
    if intelligence < 1:
        return "All stats should be no less than 1"
    if charisma < 1:
        return "All stats should be no less than 1"
    if strength > 4:
        return "All stats should be no more than 4"
    if intelligence > 4:
        return "All stats should be no more than 4"
    if charisma > 4:
        return "All stats should be no more than 4"
    if (strength + intelligence+ charisma) != 7:
        return'The character should start with 7 points'
    return name+('\nSTR' + full_dot*strength+empty_dot*(10-strength)) + ( '\nINT' +full_dot*intelligence+empty_dot*(10-intelligence))+ ('\nCHA' +full_dot*charisma+empty_dot*(10-charisma))
    
create_character('ren',4,2,1)

This is the code I was using before I switched to hard coding, it didn’t help get past problem 18 and it isn’t helping me get past problem 19. Please try using it on your end so I can know whether the problem is my code or maybe my pc is broken

When you test, you need to wrap your function call in print() so you can see what your code is returning in the console.

Test your code like this to compare actual to expected:

print('Actual:   ',repr(create_character('ren', 4, 2, 1))) 
print('Expected: ',repr('ren\nSTR ●●●●○○○○○○\nINT ●●○○○○○○○○\nCHA ●○○○○○○○○○'))

It looks like you just need to tweak the spacing.

Thank you very much I have solved it.