Build an RPG Character - Build an RPG Character

Tell us what’s happening:

The code seems to work but I cant get the last two tests:
11. create_character(‘ren’, 4, 2, 1) should return ren\nSTR ●●●●○○○○○○\nINT ●●○○○○○○○○\nCHA ●○○○○○○○○○.
12. When create_character is called with valid values it should output the character stats as required."

Sorry if its not the most concise code, Im new to this

Your code so far

full_dot = '●'
empty_dot = '○'

def create_character(name,strength,intelligence,charisma):
    #Check Name
    if type(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'
    else:
        print(name)
        #Check Stats
        if not type(strength)==int or not type(intelligence)==int or not type(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'
        else:
            STR='STR'+' '+ full_dot*strength + empty_dot*(10-strength)
            INT='INT'+' '+ full_dot*intelligence + empty_dot*(10-intelligence)
            CHA='CHA'+' '+ full_dot*charisma + empty_dot*(10-charisma)
            result = print(STR +"\n"+ INT +"\n"+ CHA)
            return result

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/141.0.0.0 Safari/537.36 OPR/125.0.0.0

Challenge Information:

Build an RPG Character - Build an RPG Character

Tell us what’s happening:

Idk whats wrong, it seems to run fine but the last two tests say failed:
11. create_character(‘ren’, 4, 2, 1) should return ren\nSTR ●●●●○○○○○○\nINT ●●○○○○○○○○\nCHA ●○○○○○○○○○.
12. When create_character is called with valid values it should output the character stats as required.

Also Im sorry its not super professional or concise, this is my first time coding.

Your code so far

full_dot = '●'
empty_dot = '○'

def create_character(name,strength,intelligence,charisma):
    #Check Name
    if type(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'
    else:
        print(name)
        #Check Stats
        if not type(strength)==int or not type(intelligence)==int or not type(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'
        else:
            STR='STR'+' '+ full_dot*strength + empty_dot*(10-strength)
            INT='INT'+' '+ full_dot*intelligence + empty_dot*(10-intelligence)
            CHA='CHA'+' '+ full_dot*charisma + empty_dot*(10-charisma)
            result = print(STR +"\n"+ INT +"\n"+ CHA)
            return result

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/141.0.0.0 Safari/537.36 OPR/125.0.0.0

Challenge Information:

Build an RPG Character - Build an RPG Character

Welcome to the forum @kmmdj

Try removing all the print calls in the function.

Happy coding

Hi @kmmdj

I went ahead and combined your posts for you. In the future, just reply to the original thread to add further updates.

Thanks.

1 Like

the tests test what your function is returning

check what it is returning print("My function output is", create_character('ren', 4, 2, 1))