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