Tell us what’s happening:
Step 18 tells me that “create_character(‘ren’, 4, 2, 1) should return ren\nSTR ●●●●○○○○○○\nINT ●●○○○○○○○○\nCHA ●○○○○○○○○○” when my code return the RIGHT THING. I’m going insane trying to find out what’s wrong. I litterally get this when I run my code:
ren
STR: ●●●●○○○○○○
INT: ●●○○○○○○○○
CHA: ●○○○○○○○○○
Your code so far
full_dot = '●'
empty_dot = '○'
def create_character(name,strength,intelligence, stamina):
if type(name) != str:
return 'The character name should be a string'
elif name == '':
return 'The character should have a name'
elif len(name) > 10:
return 'The character name is too long'
elif name.find(' ') > 0:
return 'The character name should not contain spaces'
elif (type(strength)!=int or type(intelligence)!=int or type(stamina)!=int):
return 'All stats should be integers'
elif strength < 1 or intelligence < 1 or stamina <1:
return 'All stats should be no less than 1'
elif strength > 4 or intelligence > 4 or stamina > 4:
return 'All stats should be no more than 4'
elif strength + stamina + intelligence != 7:
return 'The character should start with 7 points'
else:
return f'{name}\nSTR: {full_dot*strength}{empty_dot*(10-strength)}\nINT: {full_dot*intelligence}{empty_dot*(10-intelligence)}\nCHA: {full_dot*stamina}{empty_dot*(10-stamina)}'
print(create_character('ren',4,2,1))
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:147.0) Gecko/20100101 Firefox/147.0
Challenge Information:
Build an RPG Character - Build an RPG Character