Tell us what’s happening:
in Build an RPG Character
although output is coming but still still step 11 and 12 showing wrong. it showing step 11 and 12 are wrong. my code is as follows
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)==0:
return’The character should have a name’
if len(name)>10:
return ‘The character name is too long’
if ’ ’ in name:
return ‘The character name should not contain spaces’
stats
Your code so far
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)==0:
return'The character should have a name'
if len(name)>10:
return 'The character name is too long'
if ' ' in name:
return 'The character name should not contain spaces'
stats={'STR':strength,'INT':intelligence,'CHA':charisma}
for stat in stats.values():
if not isinstance(stat, int):
return 'All stats should be integers'
for stat in stats.values():
if stat < 1:
return 'All stats should be no less than 1'
for stat in stats.values():
if stat > 4:
return 'All stats should be no more than 4'
if sum(stats.values()) != 7 :
return 'The character should start with 7 points'
char_name=name
keys=['STR','INT','CHA']
for key in keys:
stat=stats[key]
char_name+=f'\n{key} {full_dot*stat} {empty_dot*(10-stat)}'
return repr(char_name)
test_str=create_character('ren', 4, 2, 1)
print(test_str)
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
Challenge Information:
Build an RPG Character - Build an RPG Character
That are tests 11 and 12?
What debugging have you tried to see what is wrong with your code?
11.create_character('ren', 4, 2, 1) should return ren\nSTR ●●●●○○○○○○\nINT ●●○○○○○○○○\nCHA ●○○○○○○○○○.
What debugging have you tried to see what is wrong with your code?
i am unable to understand what is wrong with code. it is exactly running as per instruction
But did you try any investigation as to what is wrong? If so, what did you try? Please answer that question
yes test 11 and 12 it shows error but output is coming
What does ‘output is coming’ mean? How have you checked that the output exactly matches what the test expects?
The tests need the returned strings to be exactly what was required, down to every space.
print((test_str)) output was

then i used print(repr(test_str))

now what should i do
That’s not the output the code you posted makes though? The code you posted has spaces in different places and you put repr inside of your function for some 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)==0:
return'The character should have a name'
if len(name)>10:
return 'The character name is too long'
if ' ' in name:
return 'The character name should not contain spaces'
stats={'STR':strength,'INT':intelligence,'CHA':charisma}
for stat in stats.values():
if not isinstance(stat, int):
return 'All stats should be integers'
for stat in stats.values():
if stat < 1:
return 'All stats should be no less than 1'
for stat in stats.values():
if stat > 4:
return 'All stats should be no more than 4'
if sum(stats.values()) != 7 :
return 'The character should start with 7 points'
char_name=name
keys=\['STR','INT','CHA'\]
for key in keys:
stat=stats\[key\]
char_name+=f'\\n{key} {full_dot\*stat}{empty_dot\*(10-stat)}'
return (char_name)
test_str=create_character('ren', 4, 2, 1)
print(repr(test_str)
my code its running exactly
I’ve edited your post to improve the readability of the code. When you enter a code block into a forum post, please precede it with three backticks to make it easier to read.
You can also use the “preformatted text” tool in the editor (</>) to add the backticks.
See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').
Unfortunately I cannot actually run this version of your code because it got mangled when you posted it because you did not format it.
It does look like you don’t have exactly the same spaces in the same places as the instructions ask for in the output.
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)==0:
return’The character should have a name’
if len(name)>10:
return ‘The character name is too long’
if ’ ’ in name:
return ‘The character name should not contain spaces’
stats={‘STR’:strength,‘INT’:intelligence,‘CHA’:charisma}
for stat in stats.values():
if not isinstance(stat, int):
return ‘All stats should be integers’
for stat in stats.values():
if stat < 1:
return 'All stats should be no less than 1'
for stat in stats.values():
if stat > 4:
return 'All stats should be no more than 4'
if sum(stats.values()) != 7 :
return 'The character should start with 7 points'
char_name=name
keys=['STR','INT','CHA']
for key in keys:
stat=stats[key]
char_name+=f'\n{key} {full_dot*stat}{empty_dot*(10-stat)}'
return (char_name)
test_str=create_character(‘ren’, 4, 2, 1)
print(repr(test_str))
is it ok now
Please format your code like I showed you
test data
//my code
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)==0:
return'The character should have a name'
if len(name)>10:
return 'The character name is too long'
if ' ' in name:
return 'The character name should not contain spaces'
stats={'STR':strength,'INT':intelligence,'CHA':charisma}
for stat in stats.values():
if not isinstance(stat, int):
return 'All stats should be integers'
for stat in stats.values():
if stat < 1:
return 'All stats should be no less than 1'
for stat in stats.values():
if stat > 4:
return 'All stats should be no more than 4'
if sum(stats.values()) != 7 :
return 'The character should start with 7 points'
char_name=name
keys=['STR','INT','CHA']
for key in keys:
stat=stats[key]
char_name+=f'\n{key} {full_dot*stat}{empty_dot*(10-stat)}'
return (char_name)
test_str=create_character('ren', 4, 2, 1)
print(repr(test_str))
The spacing is the output string is not perfectly identical to the instructions
when i was looking into one more time
code their i find extra space and same you said. thanks
1 Like