I am on the " Build an RPG Character" lab
test#2 fails: when create a character is called with a first argument that is not a string it should return " The character name should be a string '" what i did: * I added print(repr(create_character(123, 1, 1 ,1)))
to my code it prints “The character name should be a string”(exactly as required no extra spaces, no hidden characters)
the test still fails
is this a bug in test runner, or am i missing something??
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 name == "":
return "The character should have a name."
if ' ' in name:
return "The character name should not contain spaces."
stats = {"STR": strength, "INT": intelligence, "CHA": charisma}
for stat_name, value in stats.items():
if not isinstance(value, int):
return "All stats should be integers."
if value < 1:
return " All stats should be no less than 1."
if value > 4:
return " All stats should be no more than 4."
if sum(stats.values()) != 7:
return "The character should start with 7."
line1 = name
line2 = f"STR {full_dot * strength}{empty_dot * (10 - strength)}"
line3 = f"INT {full_dot * intelligence}{empty_dot *(10 - intelligence)}"
line4 = f"CHA {full_dot * charima}{empty_dot *(10 - charisma)}"
return f"{line1}\n{line2}\n{line3}\n{line4}"
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36
Yes I checked it and the output is exactly this . I feel so stuck I’ve been working on this since afternoon I’ve checked all the ways it still shows the exact same issue
i removed the periods and the problem i am facing now is step 1&2 are correct but from 3 alternatively its showing error…like 3..5..7..till 13 then 14th is correct and from 15 to 19 its all wrong again …now I’m even more confused about what’s happening.
You’re welcome. Please don’t let this overwhelm you. You’re doing great…your logic is solid. You just have a typo and a couple more errors with non-matching messages re: spacing.