Tell us what’s happening:
i nested all my conditions to make sure the last return only will be made if all conditions prior are satisfied. the test wont pass further than Test 3, returning “The character name is too long”
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 isinstance(name.find(" "), int):
return "The character name should not contain spaces"
if not isinstance(strength, int) or not isinstance(intelligence, int) or not isinstance(charisma, int):
return "All stats should be integers"
if strength < 1 or intelligence < 1 or charisma < 1:
return "All stats should be no less than 1"
if strength > 4 or intelligence > 4 or charisma > 4:
return "All stats should be no more than 4"
if not strength + intelligence + charisma == 7:
return "The character should start with 7 points"
return name + "\nSTR " + "●" * strength + "○" * (10 - strength) + "\nINT " + "●" * intelligence + "○" * (10 - intelligence) + "\nCHA " + "●" * charisma + "○" * (10 - charisma)
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36
Challenge Information:
Build an RPG character - Build an RPG Character
https://www.freecodecamp.org/learn/full-stack-developer/lab-rpg-character/build-an-rpg-character