Tell us what’s happening:
please help me fix whatever is wrong in my code in order to pass the tests.
Your code so far
full_dot = '●'
empty_dot='○'
def create_character(name,strength,intelligence,charisma):
stats = (strength,intelligence,charisma)
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):
return 'All stats should be integers'
elif not isinstance(intelligence,int):
return 'All stats should be integers'
elif not isinstance(charisma,int):
return 'All stats should be integers'
elif strength<1:
return 'All stats should be no less than 1'
elif intelligence<1:
return 'All stats should be no less than 1'
elif charisma<1:
return 'All stats should be no less than 1'
elif strength>4:
return 'All stats should be no more than 4'
elif intelligence>4:
return 'All stats should be no more than 4'
elif charisma>4:
return 'All stats should be no more than 4'
elif sum(stats) !=7:
return 'The character should start with 7 points'
else:
str_line = '\nSTR' + full_dot * strength + empty_dot * (10 - strength)
int_line = '\nINT' + full_dot * intelligence + empty_dot * (10 - intelligence)
cha_line = '\nCHA' + full_dot * charisma + empty_dot * (10- charisma)
return f'{name}{str_line}{int_line}{cha_line}'
print(repr((create_character('ren', 4, 2, 1))))
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36
Challenge Information:
Build an RPG Character - Build an RPG Character