Tell us what’s happening:
"Failed:5. The create_character function should not say that the character is too long when it’s not longer than 10 characters.
"
I acually dont know what this test wants. I am grateful for any help.
It reads to me kind of like the 4th Test with the difference that it talks about “the character” instead of the name and the double negative :
“4. When create_character is called with a first argument that is longer than 10 characters it should return 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 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"
if not all_stats_are_ints(strength, intelligence, charisma):
return "All stats should be integers"
if all_stats_are_atleast_one(strength, intelligence, charisma):
return "All stats should be no less than 1"
if all_stats_are_4_or_less(strength, intelligence, charisma):
return "All stats should be no more than 4"
if sum_of_stats(strength, intelligence, charisma) != 7:
return "The character should start with 7 points"
print (name)
print ("STR " + print_stats_dots(strength))
print ("INT " + print_stats_dots(intelligence))
print ("CHA " + print_stats_dots(charisma))
def all_stats_are_atleast_one(int1, int2, int3):
return int1 >=1 & int2 >=1 & int3 >=1
def all_stats_are_ints(int1, int2, int3):
return isinstance(int1, int) & isinstance(int2, int) & isinstance(int3, int)
def all_stats_are_4_or_less(int1, int2, int3):
return int1 <=4 & int2 <=4 & int3 <=4
def sum_of_stats(int1, int2, int3):
return int1 + int2 + int3
def print_stats_dots(number):
print (print_full_dots(strength) + print_empty_dots(10 - strength))
def print_full_dots(number):
for i in range(number):
print ('●')
def print_empty_dots(number):
for i in range(number):
print ('○')
#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/144.0.0.0 Safari/537.36 Edg/144.0.0.0
Challenge Information:
Build an RPG Character - Build an RPG Character