Build an RPG Character - Build an RPG Character

Tell us what’s happening:

why is this len() call not working??? also the return function at tthe end for the stat block isnt returning anything? :sob:

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'
    elif name!=None:
        return name

    if len(name) > 10:
        return 'The character name is too long'
    elif not len(name)<=10:
        return name

    if ' ' in name:
        return 'The character name should not contain spaces'
    elif ' ' not in name:
        return name

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


    def sbar(value):
        return full_dot * value + empty_dot * (10 - value)

    result = f"""{name}\n
    STR {sbar(strength)}\n
    INT {sbar(intelligence)}\n
    CHA {sbar(charisma)}"""
    return result
print(create_character('ren', 4, 2, 1))

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

The if condition is not working properly with len() call because you are returning the name variable and breaking out of the code before you get to the len() call.
return breaks you out of the code and returns the value and moves on to the next defined function. fix that and then if you still need help come back and reply and ill help you troubleshoot the return at the end.