I’m struggling to understand why the last if statement doesn’t pass this test: 8. When create_character is called with a second, third or fourth argument that is lower than 1 it should return All stats should be no less than 1.
Your code so far
full_dot = '●'
empty_dot = '○'
def create_character(character_name,strength,intelligence,charisma):
if not isinstance(character_name,str):
return "The character name should be a string"
if len(character_name) < 1:
return "The character should have a name"
if len(character_name) > 10:
return "The character name is too long"
if character_name.count(" ") > 0:
return "The character name should not contain spaces"
if not isinstance((strength, intelligence, charisma),int):
return "All stats should be integers"
if strength or intelligence or charisma <1:
return "All stats should be no less than 1"
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36
Hey, man! I noticed a couple of issues in your code.
First, when you write isinstance((strength, intelligence, charisma), int), you’re actually checking whether a tuple is an integer. Since it isn’t, this condition will always be true, and the function will always return "All stats should be integers". You probably want to validate each value individually.
Also, in if strength or intelligence or charisma < 1, only charisma is being compared to 1. strength and intelligence are just being evaluated as truthy values, so most valid numbers will pass this check.