Crie um personagem de RPG - Construir um Personagem de RPG

Conte-nos o que está acontecendo:

Preciso de ajuda no lab de criar um personagem RPG, no teste 3 pede para quando for colocar um nome que não passe de 10 caracteres e não consegui colocar outro código para substituir len(name) > 10 e esse é o meu código que eu consegui responder no momento:

Seu código até o momento

full_dot = '●'
empty_dot = '○'
def create_character(name, strenght, intelligence, charisma):
    # character name
    if name != str:
       return 'The character name should be a string'
    if len(name) > 10:
       return 'The character name is too  long'
    if " " in name:
       return 'The character name should not contain spaces'
    # character statics
    if strenght != int or intelligence != int or charisma != int:
       return 'All stats should be integers'
    if strenght < 1 or intelligence < 1 or charisma < 1:
       return 'All stats should be no less than 1'
    if strenght > 4 or intelligence > 4 or charisma > 4:
       return 'All stats should be no more than 4'
    if strenght + intelligence + charisma != 7:
       return 'The character should start with 7 points'
   

    

Informações do seu navegador:

Agente de usuário: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36

Informações do desafio:

Crie um personagem de RPG - Construir um Personagem de RPG

1 Like

Bem-vindo(a) ao fórum @rianfreitas120

Adicione a seguinte chamada print ao final do seu código:

print(create character(“ren”, 4, 2, 1))

Qual é a saída que você vê?

Boa programação!

there are two spaces between too and long

Consegui resolver o problema 3, mas no problema 5 não está sendo aceita a minha resposta e não consegui identificar o erro do problema.

please post your code, we are not able to help with a screenshot

full_dot = '●'
empty_dot = '○'
def create_character(name, strenght, intelligence, charisma):
    # character name
    if not isinstance(name, str):
       return 'The character name should be a string'
    if len(name) > 10:
       return 'The character name is too long'
    if " " in name:
       return 'The character name should not contain spaces'
    # character statics
    if not isinstance(strenght or intelligence or charisma, int):
       return 'All stats should be integers'
    if strenght < 1 or intelligence < 1 or charisma < 1:
       return 'All stats should be no less than 1'
    if strenght > 4 or intelligence > 4 or charisma > 4:
       return 'All stats should be no more than 4'
    if strenght + intelligence + charisma != 7:
       return 'The character should start with 7 points'

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

are you sure this is doing what you want?

Ah, eu consegui ver o problema, o insistance está lendo apenas uma das estatísticas do personagem, vou ajeitar isso.

full_dot = '●'
empty_dot = '○'
def create_character(name, strength, intelligence, charisma):
    # character name
    if not isinstance(name, str):
       return 'The character name should be a string'
    if len(name) > 10:
       return 'The character name is too long'
    if " " in name:
       return 'The character name should not contain spaces'
    # character stats
    if not all(isinstance(x, int) for x in (strength, intelligence, charisma)):
       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'
    
    strength_full = full_dot * strength
    strength_empty = (10-strength)* empty_dot
    intelligence_full = full_dot * intelligence
    intelligence_empty = (10-intelligence)* empty_dot
    charisma_full = full_dot * charisma
    charisma_empty = (10-charisma)* empty_dot

    return f"{name}\nSTR {strength_full}{strength_empty}   \nINT {intelligence_full}{intelligence_empty}\nCHA {charisma_full}{charisma_empty}"
       
print(create_character("ren", 4, 2, 1))
```**strong text**

Cheguei nesse resultado, mas não estou conseguindo terminar o desafio

Olá @rianfreitas120

Verifique se há espaços em branco extras.

Boa programação!

1 Like
full_dot = '●'
empty_dot = '○'
def create_character(name, strength, intelligence, charisma):
    # character name
    if not isinstance(name, str):
       return 'The character name should be a string'
    if len(name) > 10:
       return 'The character name is too long'
    if " " in name:
       return 'The character name should not contain spaces'
    # character stats
    if not all(isinstance(x, int) for x in (strength, intelligence, charisma)):
       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'
    
    strength_full = full_dot * strength
    strength_empty = (10-strength) * empty_dot
    intelligence_full = full_dot * intelligence
    intelligence_empty = (10-intelligence) * empty_dot
    charisma_full = full_dot * charisma
    charisma_empty = (10-charisma)* empty_dot

    return (
        f"{name}\n"
        f"STR {strength_full}{strength_empty}\n"
        f"INT {intelligence_full}{intelligence_empty}\n"
        f"CHA {charisma_full}{charisma_empty}"
    )
print(create_character("ren", 4, 2, 1))
```Consegui terminar o desafio, agradeço pelas ajudas, deu um trabalho para resolver e fico feliz que deu certo! E esse é o código que me fez passar do lab rpg! :partying_face: