Build an RPG Character - Build an RPG Character

Tell us what’s happening:

The question is to return the line if any parameters / stats are less than one while calling function. I used this below code to run but its not satisfying the test conditions.
stats={strength:‘STR’,intelligence:‘INT’,charisma:‘CHA’}
for stat in stats.values():
if stat < 1:
return ‘All stats should be no less than 1’

Your code so far

def create_character(char_name,strength,intelligence,charisma):
    if not isinstance(char_name,str):
        return 'The character name should be a string'
    if char_name== "":
        return 'The character should have a name'
    if len(char_name) > 10:
        return 'The character name is too long'
    if " " in char_name:
        return 'The character name should not contain spaces'
    if not isinstance((strength,intelligence,charisma),int):
        return 'All stats should be integers'
    stats={strength:'STR',intelligence:'INT',charisma:'CHA'}
    for stat in stats.values():
        if stat < 1:
            return 'All stats should be no less than 1'
    
    for stat in stats.values():
        if stat > 4:
            return "All stats should be no more than 4"



   
full_dot = '●'
empty_dot = '○'


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

Try testing it by calling your function and see what it returns

Try printing the stat variable

Does stats.values() contain what you expect?

as you can see the test cases passed till 7 . if after that they failed. i tried using ‘for’ and also typed the parameter individually to see if it works but nothing…. also i tried to print ‘stats’ but for some reason nothing on the console ….

This is not correct syntax.

Print stat not stats.

You also need to call your function to test it, or nothing will run.

Do not run the automated tests until you have tested each part of the function yourself. Call it with the appropriate input to trigger one of your if statements.

Please share code, not a screenshot.

I don’t see the print statement in your code.

You can’t do this. Please refer to this resource for isinstance() syntax. I don’t know why Test #7 is passing for you.

Please add print(create_character('ren',4,2,1)) in the global scope at the end of your code. You will see ‘All stats should be integers’ in the console, but clearly all stats are integers. You need to fix this before you can test the rest of your code because processing is stopping right there. That’s why you don’t see anything in the console when you try to print stats.