Build an RPG Character - Build an RPG Character

Tell us what’s happening:

Every time I run my code it says your code raised a error please fix it and try again but I can’t figure out what the error could be please help me

Your code so far

full_dot = '●'
empty_dot = '○'

def create_character(name, strength, intelligence, charisma):

    # The name checking section
    if type(name) != type("1"):
        return "The character name should be a string"
    elif len(name) == 0:
        return "The character should have a name"
    elif len(name) > 10:
        return "The character name is too long"
    elif " " in name:
        return "The character name should not contain spaces"

    # The Stat checking code
    elif type(strength) != type(1) or type(intelligence) != type(1) or type(charisma) != type(1):
        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+intellingence+charisma == 7:
        return "The character should start with 7 points"

    # The if every check is right code
    else:
        return f"{name}\n" \
        f"STR {(strength*full_dot) + (empty_dot*10) - (len(strength))}\n"\
        f"INT {(intelligence*full_dot) + (empty_dot*10) - (len(intelligence))}\n" \
        f"CHA {(charisma*full_dot) + (empty_dot*10) - (len(charisma))}\n"

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36 Edg/147.0.0.0

Challenge Information:

Build an RPG Character - Build an RPG Character

add print(create_character('ren', 4, 2, 1)) to the bottom of your code block and see if you get anything in your terminal that can help you troubleshoot.

Tell us what’s happening:

I went through my code I looked for typos and to see if I could find my error I cannot please help

Your code so far

full_dot = '●'
empty_dot = '○'

def create_character(name, strength, intelligence, charisma):
    # Character Name validation code
    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 validation code
    if not isinstance(strength, int) or not isinstance(intelligence, int) or not isinstance(charisma, int):
        return "All stats should be integers"
    if strength < 1 or intelligence < 1 or charisma < 1:
        return "All stats should be no less than 1"
    if strength > 4 or intelligence > 4 or charisma > 4:
        return "All stats should be no more than 4"
    if strength+intelligence+charisma != 7:
        return "The character should start with 7 points"
    
    return f"name\nSTR {full_dot*len(strength)}{empty_dot*(10-len(strength))}\nINT {full_dot*len(intelligence)}{empty_dot*(10-len(intelligence))}\nCHA {full_dot*len(charisma)}{empty_dot*(10-len(charisma))}"

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36 Edg/147.0.0.0

Challenge Information:

Build an RPG Character - Build an RPG Character

Hi @spydermancac,

How are you testing your code? I don’t see a function call.

Happy coding!

It just said write the function I know how to call a function, but I went with only what it said was I supposed to call it too and with what

Please test your code. If you don’t call your function, how do you know it’s returning what you expect given the parameters you’ve passed to it?

Tell us what’s happening:

I have corrected all my typos but I still can’t figure out why it doesn’t pass code check #10 can someone please help me find why my code won’t work it looks fine to me but I can’t get it to pass

Your code so far

full_dot = '●'
empty_dot = '○'

def create_character(name, strength, intelligence, charisma):

    # The name checking section
    if type(name) != type("1"):
        return "The character name should be a string"
    if len(name) == 0:
        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"

    # The Stat checking code
    sum_of_stats = strength + intelligence + charisma
    if not isinstance(strength, int) and not isinstance(intelligence, int) and not isinstance(charisma, int):
        return "All stats should be integers"
    if strength < 1 or intelligence < 1 or charisma < 1:
        return "All stats should be no less than 1"
    if strength > 4 or intelligence > 4 or charisma > 4:
        return "All stats should be no more than 4"
    if sum_of_stats == 7:
        return "The character should start with 7 points"

    # The if every check is right code
    else:
        return f"{name}\n" \
        f"STR {(strength*full_dot) + (empty_dot*10) - (len(strength))}\n"\
        f"INT {(intelligence*full_dot) + (empty_dot*10) - (len(intelligence))}\n" \
        f"CHA {(charisma*full_dot) + (empty_dot*10) - (len(charisma))}\n"

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

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36 Edg/147.0.0.0

Challenge Information:

Build an RPG Character - Build an RPG Character

I went ahead and combined your posts for you. In the future, just reply to the original thread to add further updates.

Thanks.

you can see your output vs the expected output if you write

print("actual     ", repr(create_character('ren', 4, 2, 1)))
print("expected   ", repr('ren\nSTR ●●●●○○○○○○\nINT ●●○○○○○○○○\nCHA ●○○○○○○○○○'))

When I add that below your function I see this:

actual      'The character should start with 7 points'
expected    'ren\nSTR ●●●●○○○○○○\nINT ●●○○○○○○○○\nCHA ●○○○○○○○○○'

can you check the lines that make so that The character should start with 7 points is returned?

ok I saw and fixed that error but now it says the code that checks if my second third and fourth arguments are integers is wrong

you do this before checking if they are integers, what happens if they are not integers and are data types that do not have a + operator?