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 len(name) > 10:
return 'The character name is too long.'
if ' ' in name:
return 'The character name should not contain spaces.'
stats = \[strength, intelligence, charisma\]
for stat in stats:
if not isinstance(stat, int):
return 'All stats should be integers.'
for stat in stats:
if stat < 1:
return 'All stats should be no less than 1.'
for stat in stats:
if stat > 4:
return 'All stats should be no more than 4.'
if sum(stats) != 7:
return 'The character should start with 7 points.'
def build_bar(value):
return full_dot \* value + empty_dot \* (10 - value)
result = (
f'{name}\\n'
f'STR {build_bar(strength)}\\n'
f'INT {build_bar(intelligence)}\\n'
f'CHA {build_bar(charisma)}'
)
I don’t know what’s wrong with this code I didn’t pass test 1 to 12.
I’m coding on my phone
