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
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))
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
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: