Tell us what’s happening:
Hey everyone,
I’m stuck on something I can’t quite figure out. My code runs perfectly and does everything it’s supposed to do, but it just won’t pass the test/algorithm. I’ve looked through a bunch of posts here, and most of them are really similar to what I’ve written. I didn’t want to just copy someone else’s code, but even with my version working as expected, it still fails the check. Any ideas on what might be causing that?
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 = (strength, intelligence, charisma)
for s in stats:
if not isinstance(s, int):
return "All stats should be integers."
if s < 1:
return "All stats should be no less than 1."
if s > 4:
return "All stats should be no more than 4."
if sum(stats) > 7:
return "The character should start with 7 points."
strength_full = full_dot * strength
strength_empty = (10-strength)* empty_dot
intell_full = full_dot * intelligence
intell_empty = (10-intelligence)* empty_dot
rizz_full = full_dot * charisma
rizz_empty = (10-charisma)* empty_dot
return f"{name}\nSTR {strength_full}{strength_empty}\nINT {intell_full}{intell_empty}\nCHA {rizz_full}{rizz_empty}"
character = create_character("NamesJeff", 4, 1, 2)
print(character)
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36 OPR/122.0.0.0
Challenge Information:
Build an RPG character - Build an RPG Character