Build an RPG Character - Build an RPG Character

Tell us what’s happening:

Test 8 and onward aren’t running, what’s the issue? I’ve tested other people’s solutions but they still wont run.

Your code so far

full_dot = '●'
empty_dot = '○'
def create_character(name, strength, intelligence, charisma):
#name validations
    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"
#stat validations
    stats = [strength, intelligence, charisma]
    if not isinstance(stats, 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"
    
    def make_bar(value):
        return full_dot * value + empty_dot * (10 - value)
    result = f"""{name}
    STR {make_bar(strengeth)}
    INT {make_bar(intelligence)}
    CHA {make_bar(charisma)}"""
    return result

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/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36

Challenge Information:

Build an RPG Character - Build an RPG Character

What do you mean by that?

I was looking for some help on the forum of people who had similar issues and tried their solution but none of them helped the tests run.

People won’t be posting solution code to the forum. They are posting code that does not work. So, if you copy/paste code from the forum it’s not going to work.

You need to read the threads, understand the problem and implement the solution yourself.

What does this line of code do?

sorry bad wording, I was looking at how other people wrote it.

I was using stats = [strength, intelligence, charisma] to make the code not as long but scraped that idea and did it like if strength < 1 or intelligence < 1 or charisma < 1: and forgot to delete it. I used the stats thing to write if not isinstance(stats, int): .

It wasn’t a bad idea, but either way is ok.

Best to write the code in the most simple and easy to understand way. (even if it’s longer)

Go ahead and remove that old code. Please share the updated code when you’re done.

I think I’ll have to keep it because if not isinstance(stats, int): isn’t working otherwise.

Oh are you still using that as well?

What does that line of code do?

Listen, ok, you are still using it then. Let’s go back to the first question.

stats = [strength, intelligence, charisma]

What does this line of code do?

I use it to test if any of the stats are integers or not.

if not isinstance(stats, int): tests the stats, using it combined lets it work

This line of code is a test? What does this line do?

It’s combining the stats into one variable

What kind of variable? Which type?

Uhh im not sure, Im assuming it will be a string.

It combines them all into a string?

if not isinstance(stats, int): A string isn’t an integer right? So this would always be False.

It’s not a string though. What do the square brackets do?

a = [1, 2, 3]

Does this make a a string?

b = "This is a string"

It’s makes the contents of stats a list. I am not sure if a is a string. I think it’d be the same.

Square brackets means it’s a list. so stats is a list.

if not isinstance(stats, int):

What does this line of code do? Keep in mind stats is a list, not an integer

It’s not testing if it’s a integer since it’s a list?

It IS testing if it’s an integer, but it’s always false, because it’s not an integer, it’s a list.

It does not automatically iterate through the list and look at each item. You would need to code that yourself.

I thought that’s why you gave up on it and used a bunch of or

i did for the next lines but for some reason if not isinstance(stats, int): works and solves the test “When create_character is called with a second, third or fourth argument that is not an integer it should return All stats should be integers.”

so i left it.

What does it return if all the stats are integers?