Tell us what’s happening:
I am able to see that my program is working fine, but the console says that tests 9 & 10 fail. What could be the reason
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 len(name)>10:
return "The character name is too long"
if ' ' in name:
return "The character name should not contain spaces"
attributes = \[strength, intelligence, charisma\]
if not all(isinstance(attrib,int) for attrib in attributes):
return "All stats should be integers"
if any(attrib<1 for attrib in attributes):
return "All stats should be no less than 1"
if any(attrib>4 for attrib in attributes):
return "All stats should be no more than 4"
if sum(attributes)!=7:
return "The character should start with 7 points"
def output(label, value):
total_full = full_dot\*value
total_empty = empty_dot\*(10-value)
return f"{label}{total_full}{total_empty}"
line_name = name
line_strength = output("STR",strength)
line_intelligence = output("INT", intelligence)
line_charisma = output("CHA", charisma)
return f"{line_name}\\n{line_strength}\\n{line_intelligence}\\n{line_charisma}"
user = create_character(“ren”,4,2,1)
print(user)
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 len(name)>10:
return "The character name is too long"
if ' ' in name:
return "The character name should not contain spaces"
attributes = [strength, intelligence, charisma]
if not all(isinstance(attrib,int) for attrib in attributes):
return "All stats should be integers"
if any(attrib<1 for attrib in attributes):
return "All stats should be no less than 1"
if any(attrib>4 for attrib in attributes):
return "All stats should be no more than 4"
if sum(attributes)!=7:
return "The character should start with 7 points"
def output(label, value):
total_full = full_dot*value
total_empty = empty_dot*(10-value)
return f"{label}{total_full}{total_empty}"
line_name = name
line_strength = output("STR",strength)
line_intelligence = output("INT", intelligence)
line_charisma = output("CHA", charisma)
return f"{line_name}\n{line_strength}\n{line_intelligence}\n{line_charisma}"
user = create_character("ren",4,2,1)
print(user)
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36
Challenge Information:
Build an RPG character - Build an RPG Character