Build an RPG Character - Build an RPG Character

Tell us what’s happening:

I pass every test except the last two:
Failed: 18. create_character(‘ren’, 4, 2, 1) should return ren\nSTR ●●●●○○○○○○\nINT ●●○○○○○○○○\nCHA ●○○○○○○○○○.
Failed: 19. When create_character is called with valid values it should output the character stats as required.

I have tried different ways of fixing it but I’ve been stuck for a while now. can someboy tell me what I’m missing?

Your code so far

full_dot = '●'
empty_dot = '○'

def create_character(name, STR, INT, CHA):
    
    if type(name) != str:
        print('The character name should be a string')
        return 'The character name should be a string'
    if len(name) == 0:
        print('The character should have a name')
        return 'The character should have a name'
    if len(name) > 10: #string longer than 10 characters
        print('The character name is too long')
        return 'The character name is too long'
    if ' ' in name:
        return 'The character name should not contain spaces' 
    return name
    
    if not isinstance(STR,int) or not isinstance(INT,int) or not isinstance(CHA,int):
        return 'All stats should be integers'
    if STR < 1 or INT <1 or CHA < 1:
        return 'All stats should be no less than 1'  
    if STR > 4 or INT > 4 or CHA > 4:
        return 'All stats should be no more than 4'
    if STR + INT + CHA != 7:
        return 'The character should start with 7 points'
    
    return STR
    print('STR ' + full_dot*STR + empty_dot*(10-STR))
    return INT
    print('INT ' + full_dot*INT + empty_dot*(10-INT))
    return CHA
    print('CHA ' + full_dot*CHA + empty_dot*(10-CHA))
    

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


Your browser information:

User Agent is: Mozilla/5.0 (X11; CrOS x86_64 14541.0.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.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

I suggest you remove print from inside the function, so you can check what your function is returning from this one

once you know what your function is returning and you need more help, you can ask your questions

thanks for your reply! If I do that, the output by function returns is just: ren

do you remember what happens when a return is executed?

it sends back the value of the argument into the function

you may need to review what return does, because return stops the function, and no code after is executed

meaning your function is effectively this:

okay thank you, I originally had return name at the end of the code along with the other return commands. This was just something I’ve tried out an then forgot about. If i put it back at the end I still fail the last two tesrts and the output ist just ren. If I delete it out of my code I get the output none

you can’t use multiple return statements to build the function output, only the first one will work. You need to have one return that returns the expected string

I see. thank you for taking time to reply to my problem.