Criar um personagem de RPG - Construir um personagem de RPG

Conte o que está acontecendo:

Alguém poderia me ajudar? O próximo passo, a meu ver, seria transformar full_dot de cada atributo (str, int, char) em uma integer

Seu código até agora

full_dot = '●'
empty_dot = '○'

def create_character(name, strength, intelligence, char):
    x_char = 10 - char
    res_char = char*full_dot + empty_dot*x_char

    x_intel = 10 - intelligence
    res_intel = intelligence*full_dot +    empty_dot*x_intel

    x_stren = 10 - strength
    res_stren = strength*full_dot + empty_dot*x_stren

    if not isinstance(name, str):
        return 'The character name should be a string'
    elif name == '':
        return 'The character should have a name'
    elif len(name) > 10:
        return 'The character name is too long'
    elif ' ' in name:
        return 'The character name should not contain spaces'
    elif not (isinstance(strength, int) or  isinstance(intelligence, int) or  isinstance(char, int)):
        return 'All stats should be integers'
    elif (strength or intelligence or char) < 1:
        return 'All stats should be no less than 1'
    elif (strength or intelligence or char) > 4:
        return 'All stats should be no more than 4'
    elif strength + intelligence + char != 7:
	    return 'The character should start with 7 points'

    else:
        return f'{name}\nSTR {res_stren}\nINT {res_intel}\nCHA {res_char}'

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

Informações do seu navegador:

User Agent é: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/151.0.0.0 Safari/537.36

Informações do desafio:

Criar um personagem de RPG - Construir um personagem de RPG

Link do GitHub: i18n-curriculum/curriculum/challenges/portuguese/blocks/lab-rpg-character/67d83df6f82eda3868dd2a84.md at main · freeCodeCamp/i18n-curriculum · GitHub

is it a good idea to do this before validating the values?

what happens when strength, intelligence and char are not integers?

test with print(create_character('ren', 4.1, 2, 1))

I’ve tried to put it before the conditions were approved but it kept returning the same mistake, like as long as I provide that inside the function it’d return the same error.

let’s put it an other way, what’s the point of all of this if you use strength, intelligence and char before they can be validated by this?

if you have new code, please share your new code

full_dot = '●'
empty_dot = '○'

def create_character(name, strength, intelligence, char):

    if not isinstance(name, str):
        return 'The character name should be a string'
    elif name == '':
        return 'The character should have a name'
    elif len(name) > 10:
        return 'The character name is too long'
    elif ' ' in name:
        return 'The character name should not contain spaces'
    elif not (isinstance(strength, int) or  isinstance(intelligence, int) or  isinstance(char, int)):
        return 'All stats should be integers'
    elif (strength or intelligence or char) < 1:
        return 'All stats should be no less than 1'
    elif (strength or intelligence or char) > 4:
        return 'All stats should be no more than 4'
    elif strength + intelligence + char != 7:
	    return 'The character should start with 7 points'

    x_stren = 10 - strength
    x_intel = 10 - intelligence
    x_char = 10 - char

    return f'{name}\nSTR {strength*full_dot + empty_dot*x_stren}\nINT {intelligence*full_dot + empty_dot*x_intel}\nCHA {char*full_dot + empty_dot*x_char}'

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

now you need to investigate that failure

print(create_character('ren', 4.1, 2, 1))
print(create_character('ren', 4, 2.1, 1))
print(create_character('ren', 4, 2, 1.1))

test, see what the function returns