Tell us what’s happening:
My output is same as how example says. But still test case 11 and 12 not passing. I can’t figure it out.
this is what terminal says:
/ running tests
11. create_character(‘ren’, 4, 2, 1) should return ren\nSTR ●●●●○○○○○○\nINT ●●○○○○○○○○\nCHA ●○○○○○○○○○.
12. When create_character is called with valid values it should output the character stats as required.
// tests completed
// console output
ren
STR ●●●●○○○○○○
INT ●●○○○○○○○○
CHA ●○○○○○○○○○
Your code so far
full_dot = '●'
empty_dot = '○'
def create_character(cname, strenght, intelligence, charisma):
if not isinstance(cname, str):
return "The character name should be a string"
if cname == "":
return 'The character should have a name'
if len(cname) >10:
return 'The character name is too long'
if " " in cname:
return "The character name should not contain spaces"
if not isinstance(strenght, int) or not isinstance(intelligence, int) or not isinstance(charisma, int):
return 'All stats should be integers'
if strenght <1 or intelligence < 1 or charisma < 1:
return 'All stats should be no less than 1'
if strenght > 4 or intelligence > 4 or charisma > 4:
return 'All stats should be no more than 4'
if (strenght + intelligence + charisma) != 7:
return 'The character should start with 7 points'
return f'{cname} \nSTR {full_dot*strenght + empty_dot*(10-strenght)} \nINT {full_dot*intelligence + empty_dot*(10-intelligence)} \nCHA {full_dot*charisma + empty_dot*(10-charisma)}'
result = create_character('ren', 4,2,1)
print (result)
Your browser information:
User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36
Challenge Information:
Build an RPG Character - Build an RPG Character