Every time I run my code it says your code raised a error please fix it and try again but I can’t figure out what the error could be please help me
Your code so far
full_dot = '●'
empty_dot = '○'
def create_character(name, strength, intelligence, charisma):
# The name checking section
if type(name) != type("1"):
return "The character name should be a string"
elif len(name) == 0:
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"
# The Stat checking code
elif type(strength) != type(1) or type(intelligence) != type(1) or type(charisma) != type(1):
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 strength+intellingence+charisma == 7:
return "The character should start with 7 points"
# The if every check is right code
else:
return f"{name}\n" \
f"STR {(strength*full_dot) + (empty_dot*10) - (len(strength))}\n"\
f"INT {(intelligence*full_dot) + (empty_dot*10) - (len(intelligence))}\n" \
f"CHA {(charisma*full_dot) + (empty_dot*10) - (len(charisma))}\n"
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36 Edg/147.0.0.0
add print(create_character('ren', 4, 2, 1)) to the bottom of your code block and see if you get anything in your terminal that can help you troubleshoot.
I went through my code I looked for typos and to see if I could find my error I cannot please help
Your code so far
full_dot = '●'
empty_dot = '○'
def create_character(name, strength, intelligence, charisma):
# Character Name validation code
if not isinstance(name, str):
return "The character name should be a string"
if name == "":
return "The character should have a name"
if len(name) > 10:
return "The character name is too long"
if " " in name:
return "The character name should not contain spaces"
# Stats validation code
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 strength+intelligence+charisma != 7:
return "The character should start with 7 points"
return f"name\nSTR {full_dot*len(strength)}{empty_dot*(10-len(strength))}\nINT {full_dot*len(intelligence)}{empty_dot*(10-len(intelligence))}\nCHA {full_dot*len(charisma)}{empty_dot*(10-len(charisma))}"
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36 Edg/147.0.0.0
I have corrected all my typos but I still can’t figure out why it doesn’t pass code check #10 can someone please help me find why my code won’t work it looks fine to me but I can’t get it to pass
Your code so far
full_dot = '●'
empty_dot = '○'
def create_character(name, strength, intelligence, charisma):
# The name checking section
if type(name) != type("1"):
return "The character name should be a string"
if len(name) == 0:
return "The character should have a name"
if len(name) > 10:
return "The character name is too long"
if " " in name:
return "The character name should not contain spaces"
# The Stat checking code
sum_of_stats = strength + intelligence + charisma
if not isinstance(strength, int) and not isinstance(intelligence, int) and 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 sum_of_stats == 7:
return "The character should start with 7 points"
# The if every check is right code
else:
return f"{name}\n" \
f"STR {(strength*full_dot) + (empty_dot*10) - (len(strength))}\n"\
f"INT {(intelligence*full_dot) + (empty_dot*10) - (len(intelligence))}\n" \
f"CHA {(charisma*full_dot) + (empty_dot*10) - (len(charisma))}\n"
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/147.0.0.0 Safari/537.36 Edg/147.0.0.0