ive followed the instructions but most of the tests wont pass what should i do
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 " " in name:
return 'The character name should not contain spaces.'
if len(name) > 10:
return 'The character name is too long.'
if not all(isinstance(x, int)for x in (strength, intelligence, charisma)):
return 'All stats should be integers'
if any(x < 1 for x in (strength, intelligence, charisma)):
return 'All stats should be no less than 1.'
if any(x > 4 for x in (strength, intelligence, charisma)):
return 'All stats should be no more than 4.'
if strength + intelligence + charisma != 7:
return 'The character should start with 7 points.'
return (
name + "\n" +
"STR" + " " + full_dot * strength + empty_dot * (10 - strength) +"\n" +
"INT" + " " + full_dot * intelligence + empty_dot * (10 - intelligence) + "\n" +
"CHA" + " " + full_dot * charisma + empty_dot * (10 - charisma)
)
print(create_character('ren', 4,2,1))
Your browser information:
User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36
ive followed the instructions but still most of the tests wont run
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 " " in name:
return 'The character name should not contain spaces.'
if len(name) > 10:
return 'The character name is too long.'
if not all(isinstance(x, int)for x in (strength, intelligence, charisma)):
return 'All stats should be integers'
if any(x < 1 for x in (strength, intelligence, charisma)):
return 'All stats should be no less than 1.'
if any(x > 4 for x in (strength, intelligence, charisma)):
return 'All stats should be no more than 4.'
if strength + intelligence + charisma != 7:
return 'The character should start with 7 points.'
return (
name + "\n" +
"STR" + " " + full_dot * strength + empty_dot * (10 - strength) +"\n" +
"INT" + " " + full_dot * intelligence + empty_dot * (10 - intelligence) + "\n" +
"CHA" + " " + full_dot * charisma + empty_dot * (10 - charisma)
)
print(create_character('ren', 4,2,1))
Your browser information:
User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36