I’m getting the following error message… " 3. Your code raised an error before any tests could run. Please fix it and try again."
I think it has to do with the “name” if statements section of code, but I can’t for the life of me pinpoint the issue. Would love some guidance on this one. Thanks!
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"
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"
if not isinstance(strength, int) or not isinstance(intelligence, int) or not isinstance(charisma, int):
return "All stats should be integers"
elif strength < 1 or intellgence < 1 or charisma < 1:
return "All stats should be no less than 1"
elif stregth > 4 or intelligence > 4 or charisma > 4:
return "All stats should be no more than 4"
elif strenght + intelligence + charisma != 7:
return "The character should start with 7 points"
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/150.0.0.0 Safari/537.36
Thanks for pointing that out @ILM! I fixed those spelling errors (will try to be more diligent about that moving forwards). Hm, I’m still getting the same error message in the console.
full_dot = '●'
empty_dot = '○'
def create_character(name, 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"
if not isinstance(strength, int) or not isinstance(intelligence, int) or not isinstance(charisma, int):
return "All stats should be integers"
elif strength < 1 or intelligence < 1 or charisma < 1:
return "All stats should be no less than 1"
elif strength > 4 or intelligence > 4 or charisma > 4:
return "All stats should be no more than 4"
elif strenght + intelligence + charisma != 7:
return "The character should start with 7 points"
create_character("Sam", 3, 4, 5)
the first failing test, number 3, was about what should happen when values are valid, so to test what’s happening I call the function with valid arguments, if it does not show anything, I wrap it in print, if with print it still seems exactly as asked I do print(repr(<function call here>))
if that does not give enough infos, I start adding print inside the function to check the value of all variables until I find the one that has the unexpected value