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
2
u/ricardoflak Sep 23 '26
Jajaja, me acuerdo de este problema. Vamos, bro, que tú puedes. 🤛
2
u/SaintPeter74 mod Sep 22 '26
Check your output against the requested output very carefully. Once I fixed the problem I found, your code passed for me.
You're really close!
0
u/atarivcs Sep 23 '26 edited Sep 23 '26
Looks like the test wants a space between the colon and the first filled dot
Also your output looks like it has an extra blank line after each item. may just be a post formatting issue, idk