Tell us what’s happening:
Why is my code not valid at the end? It prints exactly the same as the request?
Your code so far
def create_character(name, strength, intelligence, charisma):
stats = (strength, intelligence, charisma)
if not isinstance(name, str):
return "The character name should be a string"
elif name == "":
return "The character should have a name"
elif len(name) > 10:
return "The character name is too long"
elif " " in name:
return "The character name should not contain spaces"
elif not isinstance(strength, int):
return "All stats should be integers"
elif not isinstance(intelligence, int):
return "All stats should be integers"
elif not isinstance(charisma, int):
return "All stats should be integers"
elif sum(stats) != 7:
return "The character should start with 7 points"
for stat in stats:
if stat < 1:
return "All stats should be no less than 1"
elif stat > 4:
return "All stats should be no more than 4"
else:
empt_dots = "○○○○○○○○○○"
str_dots = "●" * strength + empt_dots[strength:]
int_dots = "●" * intelligence + empt_dots[intelligence:]
cha_dots = "●" * charisma + empt_dots[charisma:]
print(f"{name}\n STR {str_dots}\n INT {int_dots}\n CHA {cha_dots}")
return f"{name}\n STR{str_dots}\n INT{int_dots}\n CHA{cha_dots}"
create_character('ren', 4, 2, 1)
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36
Challenge Information:
Build an RPG Character - Build an RPG Character