I am not able to get past steps #18 and #19.
I genuinely do not know what the mistake is in my code
Your code so far
full_dot = '●'
empty_dot = '○'
def create_character(character_name,strength,intelligence,charisma):
if not isinstance(character_name,str):
return "The character name should be a string"
elif character_name == "":
return "The character should have a name"
elif len(character_name) > 10 :
return "The character name is too long"
elif " " in character_name :
return "The character name should not contain spaces"
elif any(not isinstance(stat,int) for stat in [strength,intelligence,charisma]) :
return "All stats should be integers"
elif any(stat <1 for stat in [strength,intelligence,charisma]) :
return "All stats should be no less than 1"
elif any(stat >4 for stat in [strength,intelligence,charisma]) :
return "All stats should be no more than 4"
elif strength+intelligence+charisma != 7 :
return "The character should start with 7 points"
else :
stats = {"STR":strength,"INT":intelligence,"CHA":charisma}
result= f"{character_name}\n"
for abbr, value in stats.items() :
full_dots= full_dot*value
empty_dots = empty_dot*(10-value)
result += f"{abbr} {full_dots}{empty_dots}\n"
return result
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/148.0.0.0 Safari/537.36
if not isinstance(character_name,str):
return "The character name should be a string"
elif character_name == "":
return "The character should have a name"
elif len(character_name) > 10 :
return "The character name is too long"
elif " " in character_name :
return "The character name should not contain spaces"
elif any(not isinstance(stat,int) for stat in \[strength,intelligence,charisma\]) :
return "All stats should be integers"
elif any(stat <1 for stat in \[strength,intelligence,charisma\]) :
return "All stats should be no less than 1"
elif any(stat >4 for stat in \[strength,intelligence,charisma\]) :
return "All stats should be no more than 4"
elif strength+intelligence+charisma != 7 :
return "The character should start with 7 points"
else :
stats = {"STR":strength,"INT":intelligence,"CHA":charisma}
result= f"{character_name}\\n"
for abbr, value in stats.items() :
full_dots= full_dot\*value
empty_dots = empty_dot\*(10-value)
result += f"{abbr} {full_dots}{empty_dots}\\n"
return result
create_character(‘ren’, 4, 2, 1)
print(repr(create_character(‘ren’, 4, 2, 1)))
this is what it is currently if its ok to post like this
It doesn’t look like you have changed anything in your code and I see this in the console: 'ren\nSTR ●●●●○○○○○○\nINT ●●○○○○○○○○\nCHA ●○○○○○○○○○\n' from print(repr(create_character(‘ren’, 4, 2, 1))). Notice the extra newline character at the end.