Tell us what’s happening:
Hello, I can’t get past cases 7, 9 and 10. Don’t know what’s happening because when I print control cases instead of returning, it seems working. Any help is appreciated.
Your code so far
import sys
full_dot = '●'
empty_dot = '○'
def create_character(firstname, strength, intelligence, charisma):
stats = (strength, intelligence, charisma)
if not isinstance(firstname,str):
return ('The character name should be a string')
if len(firstname) > 10:
return ('The character name is too long')
if " " in firstname:
return ('The character name should not contain spaces')
if (isinstance(strength,int) & isinstance(intelligence,int) & isinstance(charisma,int)) == False:
return ('All stats should be integers')
if sum(stats) != 7:
return ('The character should start with 7 points')
if any (s < 1 for s in stats):
return ('All stats should be no less than 1')
if any (s > 4 for s in stats):
return ('All stats should be no more than 4')
strtext=""
inttext=""
chatext=""
for x in range(strength):
strtext+=full_dot
for x in range(10 - strength):
strtext+=empty_dot
for x in range(intelligence):
inttext+=full_dot
for x in range(10 - intelligence):
inttext+=empty_dot
for x in range(charisma):
chatext+=full_dot
for x in range(10 - charisma):
chatext+=empty_dot
print(firstname)
print("STR", strtext)
print("INT", inttext)
print("CHA", chatext)
create_character("ren", 4, 2, 1)
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:145.0) Gecko/20100101 Firefox/145.0
Challenge Information:
Build an RPG character - Build an RPG Character