I wrote the code and am getting the right results when I run it in python on my own computer. Correct results even if I change the inputs. Yet, tests 11 and 12 always fail.
Your code so far
full_dot = '●'
empty_dot = '○'
def create_character(name, strength,intelligence, charisma):
stats = (strength, intelligence, charisma)
stats_total_max = 7
stats_ind_max = 4
stats_ind_min = 1
char_name_max_length = 10
total_dots = 10
if not isinstance(name, str):
return 'The character name should be a string'
if not name:
return 'The character should have a name'
if len(name) > char_name_max_length:
return 'The character name is too long'
if ' ' in name:
return 'The character name should not contain spaces'
for stat in stats:
if not isinstance(stat,int):
return 'All stats should be integers'
elif stat < stats_ind_min:
return 'All stats should be no less than 1'
elif stat > stats_ind_max:
return 'All stats should be no more than 4'
if sum(stats) != stats_total_max:
return 'The character should start with 7 points'
def make_bar(value,num_dots=10):
return full_dot * value + empty_dot * (num_dots - value)
results = f"""{name}
STR: {make_bar(strength,total_dots)}
INT: {make_bar(intelligence,total_dots)}
STR: {make_bar(charisma,total_dots)}"""
return results
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36 Edg/143.0.0.0
Can you give me line numbers? I am comparing my code with the instructions and am not seeing what the extra character would be. I removed the colon from lines 39-41 with no success. Everything else returns the correct output
Since I am confident that the rest of the script works as expected (all the tests show checks). I am including the last few lines. Including the lines that were recommended I add.
Here is a screenshot of the output I get. Looks like I am getting the output that is asked for.
full_dot = '●'
empty_dot = '○'
def create_character(name, strength,intelligence, charisma):
stats = (strength, intelligence, charisma)
stats_total_max = 7
stats_ind_max = 4
stats_ind_min = 1
char_name_max_length = 10
total_dots = 10
if not isinstance(name, str):
return 'The character name should be a string'
if not name:
return 'The character should have a name'
if len(name) > char_name_max_length:
return 'The character name is too long'
if ' ' in name:
return 'The character name should not contain spaces'
for stat in stats:
if not isinstance(stat,int):
return 'All stats should be integers'
elif stat < stats_ind_min:
return 'All stats should be no less than 1'
elif stat > stats_ind_max:
return 'All stats should be no more than 4'
if sum(stats) != stats_total_max:
return 'The character should start with 7 points'
def make_bar(value,num_dots=10):
return full_dot * value + empty_dot * (num_dots - value)
print(f"runs command: create_character('{name}',{strength},{intelligence},{charisma})") #to compare input
print(f"{name}\nSTR {make_bar(strength,total_dots)}\nINT {make_bar(intelligence,total_dots)}\nCHA {make_bar(charisma,total_dots)}")
create_character('ren',2,3,2)
I removed them in favor of a single line. Though I probably could have done something like return results
This is what I replaced it with. return f"{name}\nSTR {make_bar(strength,total_dots)}\nINT {make_bar(intelligence,total_dots)}\nCHA {make_bar(charisma,total_dots)}"