Build an RPG Character - Build an RPG Character

Tell us what’s happening:

im facing a TypeError which says “‘<’ not supported between instances of ‘dict’ and ‘int’” what did I do 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 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': strength,'INT': intelligence, 'CHA': charisma }

    for stats in stats.values():
        if type(stats) != int:
            return "All stats should be integers"
        if stats<1:
            return 'All stats should be no less than 1'
        if stats>4:
            return 'All stats should be no more than 4'
    if sum(stats) > 7:
        return 'The character should start with 7 points'
    
    return name
    return 'STR ',full_dot*strength,empty_dot*(10-strength)
    return 'INT ',full_dot*intelligence, empty_dot*(10-intelligence)
    return 'CHA ', full_dot*charisma, empty_dot*(10-charisma)

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/147.0.0.0 Safari/537.36

Challenge Information:

Build an RPG Character - Build an RPG Character

Github Link: freeCodeCamp/curriculum/challenges/english/blocks/lab-rpg-character/67d83df6f82eda3868dd2a84.md at main · freeCodeCamp/freeCodeCamp · GitHub

please don’t do this, don’t reuse an existing variable in the loop, give it an unique name

like declare a new variable just for the loop?

yes, otherwise how can you be sure what is the value of stats?

and here, after the loop, what is the value of stats?

the addition of all of the elements? is there a different syntax for when its in a list?

no, because now stats does not have the value from stats={'STR': strength,'INT': intelligence, 'CHA': charisma }, it has the value from for stats in stats.values():

so please do not overwrite variables, use a new variable in the loop

okay got it, thank you so much for the help!