Build an RPG Character - Build an RPG Character

Tell us what’s happening:

not meeting criteria 10 which asks to evaluate the stats to see if they are not integers. I’ve tested it however and it does work and it even tells me when I test floats in the function call that they aren’t integers. maybe I gotta re-write it again? this is the only criteria I need

Your code so far

full_dot = '●'
empty_dot = '○'
def create_character(name, STR, INT, CHA):
    if not isinstance(name, str):
        return "The character name should be a string"
    if name == '':
        return "The character should have a name"
    if len(name) > 10:
        return "The character name is too long"
    if ' ' in name:
        return "The character name should not contain spaces"
    stats = [STR, INT, CHA]
    stats_sum = STR + INT + CHA
    for stat in stats:
        if stat < 1:
            return "All stats should be no less than 1"
        if stat > 4:
            return "All stats should be no more than 4"
        if not isinstance(stat, int):
            return "All stats should be integers"
    if stats_sum != 7:
            return "The character should start with 7 points"
    def bar(value):
        return full_dot*value + empty_dot*(10-value)

    return f'{name}\nSTR {bar(STR)}\nINT {bar(INT)}\nCHA {bar(CHA)}'

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

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.3.1 Safari/605.1.15

Challenge Information:

Build an RPG Character - Build an RPG Character

Hey @AllAlexx, and welcome to the FCC Community! Glad to have you here.

Take a close look at the logic of your steps. There are a couple observations to make. STR, INT, and CHA must be a number (specifically integer) type in order to be summed. Take into consideration that you should check these values before you try to sum them.

Additionally, pay close attention to the if statements inside your for loop. If I have something that is not a number, how can it ever be less than 1 or greater than 4? I think the first check would be to see if it’s an integer or not and then check it against other numbers.

Fix those gaps in the logic for this step, and we’ll make an adventurer out of you yet!

1 Like

will do! thank you for the guidance

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.