Build an RPG Character - Build an RPG Character

Tell us what’s happening:

I seem to have an issue starting with line 18! everything before checks out. Help, please!

Your code so far

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 isinstance(intelligence, int) or isinstance(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'
    strength_in_balls = (strength * full_dot) + ((10 - strength) * empty_dot)
    intelligence_in_balls = (intelligence * full_dot) + ((10 - intelligence) * empty_dot)
    charisma_in_balls = (charisma * full_dot) + ((10 - charisma) * empty_dot) 
    return f'''
    {character_name}
    STR {strength_in_balls}
    INT {intelligence_in_balls}
    CHA {charisma_in_balls}'''

    

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.2 Safari/605.1.15

Challenge Information:

Build an RPG Character - Build an RPG Character

What is your problem?

1 Like

try to check what your function is doing for the failed tests, do not assume where the issue is

add this at the end in the editor to see what your function is returning for the failed tests

print("actual  ", repr(create_character('ren', 0, 3, 4)))
print("actual  ", repr(create_character('ren', 3, 0, 4)))
print("actual  ", repr(create_character('ren', 3, 4, 0)))
print("expected", repr("All stats should be no less than 1"), "\n")
print("actual  ", repr(create_character('ren', 5, 1, 1)))
print("actual  ", repr(create_character('ren', 1, 5, 1)))
print("actual  ", repr(create_character('ren', 1, 1, 5)))
print("expected", repr("All stats should be no more than 4"), "\n")
print("actual  ", repr(create_character('ren', 2, 2, 2)))
print("expected", repr("The character should start with 7 points"), "\n")
print("actual  ", repr(create_character('ren', 4, 2, 1)))
print("expected", repr("ren\nSTR ●●●●○○○○○○\nINT ●●○○○○○○○○\nCHA ●○○○○○○○○○"), "\n")
1 Like