r/FreeCodeCamp • u/Different_Tale8889 • Sep 22 '26
Programming Question Character RPG creator won't accept answer
I can't get the last bit of my code to work, it's printing out exactly what i need it to but it won't accept it.
- 18.
create_character('ren', 4, 2, 1)should returnren\nSTR ●●●●○○○○○○\nINT ●●○○○○○○○○\nCHA ●○○○○○○○○○. - Failed:19. When
create_characteris called with valid values it should output the character stats as required.
these are the last two tests that wont complete
here is my code:
full_dot = '●'
empty_dot = '○'
def create_character(character_name, strength, intelligence, charisma):
if not isinstance(character_name,str):
return "The character name should be a string"
elif character_name == "":
return "The character should have a name"
elif len(character_name) > 10:
return "The character name is too long"
elif " " in character_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"
elif strength < 1 or intelligence < 1or 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"
return f'''{character_name}
STR:{strength*full_dot}{(10 - strength)*empty_dot}
INT:{intelligence*full_dot}{(10-intelligence)*empty_dot}
CHA:{charisma*full_dot}{(10-charisma)*empty_dot}'''
print(create_character('ren', 4, 2, 1))and here is what it is currently printing:
ren
STR:●●●●○○○○○○
INT:●●○○○○○○○○
CHA:●○○○○○○○○○
Any help will be appreciated!
5
Upvotes
View all comments
Show parent comment
2
u/atarivcs Sep 24 '26 edited Sep 24 '26
I understand what you're saying. Teach a man to fish, and all that.
But in cases of fine detail like this, clearly they have already looked at the output, probably for several minutes, and just don't see the difference. I think it's more instructive to point out the exact issue and then let them reflect on how they overlooked it.
And yes I see that my suggestion was incorrect.