My case test 10 is not passing. Can someone help me? The logic is correct, the output is matching the test string but the last test case is not passing
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)>=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"
character_string=name
for key in ['STR', 'INT', 'CHA']:
stat = stats[key]
character_string += f'\n{key} {full_dot*stat}{empty_dot*(10-stat)}'
return character_string
print(create_character("ren",4,2,1))
test_str = 'ren\nSTR ●●●●○○○○○○\nINT ●●○○○○○○○○\nCHA ●○○○○○○○○○'
print(f"{test_str}")
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36
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.
yes the name is printing correct in the output as the test case print(create_character("catanddogs",4,2,1)) this is giving the character name too long which is also correct, but case test is not passing
hi @shrashti please create your own post to ask your question
If you have a question about a specific challenge as it relates to your written code for that challenge and need some help, click the Get Help > Ask for Help button located on the challenge.
The Ask for Help button will create a new topic with all code you have written and include a link to the challenge also. You will still be able to ask any questions in the post before submitting it to the forum.
It is great that you solved the challenge, but instead of posting your full working solution, it is best to stay focused on answering the original poster’s question(s) and help guide them with hints and suggestions to solve their own issues with the challenge. How to Help Someone with Their Code Using the Socratic Method
We are trying to cut back on the number of spoiler solutions found on the forum and instead focus on helping other campers with their questions and definitely not posting full working solutions.
It is great that you solved the challenge, but instead of posting your full working solution, it is best to stay focused on answering the original poster’s question(s) and help guide them with hints and suggestions to solve their own issues with the challenge. How to Help Someone with Their Code Using the Socratic Method
We are trying to cut back on the number of spoiler solutions found on the forum and instead focus on helping other campers with their questions and definitely not posting full working solutions.