Build an RPG Character - Build an RPG Character

Tell us what’s happening:

im really not grasping the syntax here. i can delete some things and it breaks some goals and fixes other ones. i need a little more direct advice to help understand this, less hinty hint please. ive gone back over my notes several times and im just not seeing what im doing wrong

Your code so far

full_dot = '●'
empty_dot = '○'

def create_character(name, strength, intelligence, charisma):
    
    if not isinstance(name,str):return 'The character name should be a string'
    if ' ' in name:return 'The character should have a name'
    if len(name)>10:return 'The character name is too long'

    stats=[strength, intelligence, charisma]
    if not all(isinstance(stats, int)):
        return "All stats should be integers."
    if any(stats<1):
        return "All stats should be no less than 1"
    if any(stats > 4 ):
        return "All stats should be no more than 4"
    if sum(stats!=7):return 'The character should start with 7 points'

Your browser information:

User Agent is: Mozilla/5.0 (X11; Linux x86_64; rv:149.0) Gecko/20100101 Firefox/149.0

Challenge Information:

Build an RPG Character - Build an RPG Character

what do you get in your terminal when you add this line of code to the vary bottom of the blocks you have written so far?

print(create_character(‘ren’, 4, 2, 1))

it spits back an error about booleans not being iterable. i have no idea what that means

Hi @livingfields,

And that error message is giving you some important information:

Traceback (most recent call last):
  File "main.py", line 19, in <module>
  File "main.py", line 11, in create_character
TypeError: 'bool' object is not iterable

What line number is the error pointing you to? What’s the bool object on that line? Check to see if you are using the correct syntax for that validation.

Happy coding!

if not all(isinstance(stats, int)):
        return "All stats should be integers."

thats line 11. i understand now that you have to phrase the syntax to check a list and you cant use the list name as a variable for whatever reason. so i changed it to a list, seemingly like it should be cataloging the list in boolean values and check against if its False or not, but not only is it not doing that but somehow its now spitting back an error that i dont have a function named create_character when its clearly the first line of an actual code block that isnt designating global variables.

full_dot = '●'
empty_dot = '○'

def create_character(name, strength, intelligence, charisma):
    
    if not isinstance(name,str):return 'The character name should be a string'
    if ' ' in name:return 'The character should have a name'
    if len(name)>10:return 'The character name is too long'

    stats=[strength, intelligence, charisma]
    if not all [type(int) in stats]:
        return "All stats should be integers."
    if any(stats<1):
        return "All stats should be no less than 1"
    if any(stats > 4 ):
        return "All stats should be no more than 4"
    if sum(stats!=7):return 'The character should start with 7 points'
print(create_character('ren', 4, 2, 1))

also thank you again for coming to my rescue <3

You still have an issue on Line 11. Aren’t you seeing an error in the console?

Please look up the syntax for using all() to iterate over a list to check list item type.

i know i do thats what im trying to figure out :sob:

which section is all() in again i forget and the search on here is terrible

full_dot = '●'
empty_dot = '○'

def create_character(name, strength, intelligence, charisma):
    
    if not isinstance(name,str):return 'The character name should be a string'
    if ' ' in name:return 'The character should have a name'
    if len(name)>10:return 'The character name is too long'

    stats=[strength, intelligence, charisma]
    for cha_stat in stats:
        if not cha_stat==int:
            return "All stats should be integers."
    if any(stats<1):
        return "All stats should be no less than 1"
    if any(stats > 4 ):
        return "All stats should be no more than 4"
    if sum(stats!=7):return 'The character should start with 7 points'
print(create_character('ren', 4, 2, 1))

nowwwww were cookin. thank you for your help again

also dont worry its still broken LOL

You could have also just googled “python how to use all() to iterate over a list to check list item type”. Much simpler than looking through forum posts and possibly copying someone else’s errors.

yeah ive been trying to combine research on google with notes ive taken, the lessons ive gone through, and stuff i can actively remember. this course has honestly shown me i can definitely do this, its just gonna take a fair bit of learning