Build an RPG Character - Build an RPG Character

Tell us what’s happening:

The following test is not letting me pass. but idk what the problem might be
5. The create_character function should not say that the character is too long when it’s not longer than 10 characters.

Your code so far

full_dot = '●'
empty_dot = '○'

def create_character(char_name, strength, intelligence, charisma):
    if not isinstance(char_name, str):
        return "The character name should be a string"
    if bool(char_name) == False:
        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 type(strength) != int or type(intelligence) != int or type(charisma) != 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"
    global full_dot
    global empty_dot
    full_dot *= strength
    empty_dot *= 10-strength
    stre_vis = full_dot + empty_dot
    full_dot *= intelligence
    empty_dot *= 10-intelligence
    inte_vis = full_dot + empty_dot
    full_dot *= charisma
    empty_dot *= 10-charisma
    cha_vis = full_dot + empty_dot
    return char_name + "/n" + "STR" + " " + stre_vis + "\n" + "INT" + " " + inte_vis + "\n" + "CHA" + " " + cha_vis

create_character('ren', 4, 2, 1)

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:146.0) Gecko/20100101 Firefox/146.0

Challenge Information:

Build an RPG Character - Build an RPG Character

Try testing your function with different input and printing the results.

1 Like

already found the problem. somehow test 5 doesn’t work if the overall output is too long (I had to many empty dots, my test for name length worked fine)

1 Like

it was failing because of a MemoryError, something in your output was too big and it was killing the process before it could test

changing global variables is not a good way to do it, I hope you understood now

1 Like