Raccontaci cosa sta succedendo:
Ho bisogno di aiuto per controllare il mio codice
Il tuo codice finora
full_dot = '●'
empty_dot = '○'
def create_character(name, strength, intelligence, charisma):
if not isinstance (name, str):
return 'The character name should be a string'
if name == '':
return 'The character should have a name'
if name > name[:10]:
return 'The character name is too long'
if ' ' in name :
return 'The character name should not contain spaces'
if not (isinstance(strength, int) and isinstance(intelligence, int) and isinstance(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'
if name and strength and intelligence and charisma:
return f'{name}\nSTR {strength * (full_dot + " ")}{(10 - strength) * (empty_dot + " ")}\nINT {intelligence * (full_dot + " ")}{(10 - intelligence) * (empty_dot + " ")}\nCHA {charisma * (full_dot + " ")}{(10 - charisma) * (empty_dot + " ")}\n'
print (create_character('ren', 4, 2, 1))
Informazioni sul tuo browser:
User Agent è: Mozilla/5.0 (Android 14; Mobile; rv:157.0) Gecko/157.0 Firefox/157.0
Informazioni sulla sfida:
Crea un personaggio RPG - crea un personaggio per un rpg
Collegamento GitHub: i18n-curriculum/curriculum/challenges/italian/blocks/lab-rpg-character/67d83df6f82eda3868dd2a84.md at main · freeCodeCamp/i18n-curriculum · GitHub