Tell us what’s happening:
why wont my code pass the validation tests yet the other parts work???
Your code so far
full_dot = '●'
empty_dot = '○'
def create_character(name, strength, intelligence, charisma):
# name and stat validation (same as before)
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]
if not all(isinstance(stat, int) for stat in stats):
return "All stats should be integers."
if any(stat < 1 for stat in stats):
return "All stats should be no less than 1."
if any(stat > 4 for stat in stats):
return "All stats should be no more than 4."
if sum(stats) != 7:
return "The character should start with 7 points."
# ---- Building the final text ----
name_line = name
# For strength line:
full_dots = '●' * strength
empty_dots = '○' * (10 - strength)
strength_line = "STR " + full_dots + empty_dots
# For intelligence line:
full_dots = '●' * intelligence
empty_dots = '○' * (10 - intelligence)
intelligence_line = "INT " + full_dots + empty_dots
# For charisma line:
full_dots = '●' * charisma
empty_dots = '○' * (10 - charisma)
charisma_line = "CHA " + full_dots + empty_dots
# Combine all four lines into one string
result = name_line + "\n" + strength_line + "\n" + intelligence_line + "\n" + charisma_line
return result
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36
Challenge Information:
Build an RPG character - Build an RPG Character