everything works as needed, but still giving errors like:
2. When create_character is called with a first argument that is not a string it should return The character name should be a string.
3. When create_character is called with a first argument that is longer than 10 characters it should return The character name is too long.
and etc.
What’s wrong?
Your code so far
full_dot = '●'
empty_dot = '○'
def create_character(name, strength, intelligence, charisma):
STRfull = ""
STRem = ""
INTfull = ""
INTem = ""
CHAfull = ""
CHAem = ""
#checking
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.')
if not isinstance(strength, int) or not isinstance(intelligence, int) or not 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 passed all
for x in range(strength):
STRfull = STRfull + full_dot
for x in range(10-strength):
STRem = STRem + empty_dot
for x in range(intelligence):
INTfull = INTfull + full_dot
for x in range(10-intelligence):
INTem = INTem + empty_dot
for x in range(charisma):
CHAfull = CHAfull + full_dot
for x in range(10-charisma):
CHAem = CHAem + empty_dot
return (f'{name} \nSTR {STRfull}{STRem} \nINT {INTfull}{INTem} \nCHA {CHAfull}{CHAem}')
print(create_character("ren", 4, 2, 1))
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36 OPR/122.0.0.0
oke i fixed the text, but 9-10 stories still not marked as completed. (i know what doing dot-caharacteristic with extra variables is a dumb thing, but im trying my best ;_;). can you advise me any other solution of this problem?
full_dot = ‘●’
empty_dot = ‘○’
def create_character(name, strength, intelligence, charisma):
STRfull = ""
STRem = ""
INTfull = ""
INTem = ""
CHAfull = ""
CHAem = ""
#checking
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')
if not isinstance(strength, int) or not isinstance(intelligence, int) or not 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 passed all
for x in range(strength):
STRfull = STRfull + full_dot
for x in range(10-strength):
STRem = STRem + empty_dot
for x in range(intelligence):
INTfull = INTfull + full_dot
for x in range(10-intelligence):
INTem = INTem + empty_dot
for x in range(charisma):
CHAfull = CHAfull + full_dot
for x in range(10-charisma):
CHAem = CHAem + empty_dot
return (f'{name} \\nSTR {STRfull}{STRem} \\nINT {INTfull}{INTem} \\nCHA {CHAfull}{CHAem}')
print(create_character(“ren”, 4, 2, 1))