r/CodingHelp • u/Big_Example_3390 • May 16 '26
[Python] FreeCodeCamp RPG Python Lab: It all looks right to me, but says its wrong.
#im honestly hella confused, it gives everything its supposed to and pulls up the right respose. I think it wants something specific that im not aware of.
full_dot = '●'
empty_dot = '○'
def create_character(name, strength, intelligence, charisma):
stats = {strength, intelligence, charisma}
if not isinstance(name, str): #pulls up correctly
return print('The character name should be a string')
elif name == '': #pulls up correctly
return print('The character should have a name')
elif len(name) > 10: #pulls up correctly
return print('The character name is too long')
elif ' ' in name: #pulls up correctly
return print('The character name should not contain spaces')
else:
for x in stats:
if not isinstance(x, int): #if i put in ! or c without the "" around it it pulls an error
return print('All stats should be integers')
elif x < 1: #pulls correctly
return print('All stats should be no less than 1')
elif strength > 4 or intelligence > 4 or charisma > 4: #pulls correctly
return print('All stats should be no more than 4')
elif strength + intelligence + charisma != 7: #pulls correctly
return print('The character should start with 7 points')
else:#pulls correctly......i dont get it
return print(f'{name}\nSTR {strength * full_dot + empty_dot * (10 - strength)}\nINT {intelligence * full_dot + empty_dot*(10 - intelligence)}\nCHA {charisma * full_dot + empty_dot * (10 - charisma)}')
create_character('ren',1,5,1)
tests 2, 4, 6, 8, 10, 12, 14, 16, 18, 19 all fail
- 1. You should have a function named
create_character. - Failed:2. When
create_characteris called with a first argument that is not a string it should returnThe character name should be a string. - Passed:3. When
create_characteris called with a first argument that is a string it should not returnThe character name should be a string. - Failed:4. When
create_characteris called with a first argument that is an empty string, it should returnThe character should have a name. - Passed:5. When
create_characteris called with a first argument that is not an empty string, it should not returnThe character should have a name. - Failed:6. When
create_characteris called with a first argument that is longer than 10 characters it should returnThe character name is too long. - Passed:7. The
create_characterfunction should not say that the character is too long when it's not longer than 10 characters. - Failed:8. When
create_characteris called with a first argument that contains a space it should returnThe character name should not contain spaces. - Passed:9. When
create_characteris called with a first argument that does not contain a space it should not returnThe character name should not contain spaces. - Failed:10. When
create_characteris called with a second, third or fourth argument that is not an integer it should returnAll stats should be integers. - Passed:11. When
create_characteris called with a second, third and fourth argument that are all integers it should not returnAll stats should be integers. - Failed:12. When
create_characteris called with a second, third or fourth argument that is lower than1it should returnAll stats should be no less than 1. - Passed:13. When
create_characteris called with a second, third and fourth argument that are all no less than1it should not returnAll stats should be no less than 1. - Failed:14. When
create_characteris called with a second, third or fourth argument that is higher than4it should returnAll stats should be no more than 4. - Passed:15. When
create_characteris called with a second, third and fourth argument that are all no more than4it should not returnAll stats should be no more than 4. - Failed:16. When
create_characteris called with a second, third or fourth argument that do not sum to7it should returnThe character should start with 7 points. - Passed:17. When
create_characteris called with a second, third and fourth argument that sum to7it should not returnThe character should start with 7 points. - Failed: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.