Tell us what’s happening:
My code is failing at test 11 and some after as well. Trying to just understand why it is failing at test 11 right now. The code is returning ‘All stats should be integers’ after testing it. I have read through the forums for the past few days trying to figure out why and copying other’s ideas to try to find a solution but I am not sure why my code is displaying ‘All stats should be integers’
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'
stats = [strength, intelligence, charisma]
if not all(isinstance(stats, int) for stat in stats):
return 'All stats should be integers'
elif stats < 1:
return 'All stats should be no less than 1'
elif stats > 4:
return 'All stats should be no more than 4'
elif sum(stats) != 7:
return 'The character should start with 7 points'
else:
return
'name'
'\nSTR '(full_dot*strength)+((10-strength)*empty_dot)
'\nINT '(full_dot*intelligence)+((10-intelligence)*empty_dot)
'\nCHA '(full_dot*charisma)+((10-charisma)*empty_dot)
print(create_character('ren', 4, 2, 1))
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36
Challenge Information:
Build an RPG Character - Build an RPG Character
