Tell us what’s happening:
OUTPUT from my coded when running in Geany
ren
STR ●●●●○○○○○○
INT ●●○○○○○○○○
CAR ●○○○○○○○○○
The character name should be a string.
The character should have a name.
The character name is too long.
The character name should not contain spaces.
All stats should be integers.
All stats should be no less than 1.
All stats should be no more than 4.
The character should start with 7 points.
(program exited with code: 0)
Your code so far
full_dot = '●'
empty_dot = '○'
def show_dots(nmbr):
astr = full_dot * nmbr + empty_dot * ( 10 - nmbr)
return astr
def create_character(name, strength, intelligence, carisma):
if type(name) is not str:
return "The character name should be a string."
if len(name)<1 :
return("The character should have a name.")
if(len(name)>10):
return("The character name is too long.")
if(name.count(' ')>0):
return("The character name should not contain spaces.")
# all stats must be integer
if((type(strength) != int) or
(type(intelligence) != int) or
(type(carisma) != int) ):
return("All stats should be integers.")
# all stats must > 1
if((strength <1) or (intelligence<1) or (carisma<1) ):
return("All stats should be no less than 1.")
# All stats should be no more than 4.'
if((strength >4) or (intelligence >4) or (carisma>4) ):
return("All stats should be no more than 4.")
# If the sum of all stats is different than 7,
if strength + intelligence + carisma != 7:
return("The character should start with 7 points.")
return (name +
"\nSTR "+ show_dots(strength) +
"\nINT "+ show_dots(intelligence) +
"\nCAR "+ show_dots(carisma))
#
print (create_character('ren', 4, 2, 1))
print (create_character(20,3,4,5))
print (create_character("",2,3,4))
print (create_character("thunderbolt",2,3,4))
print (create_character("thunde t",2,3,4))
print (create_character("thunde",2,"bla",4))
print (create_character("thunde",0,3,4))
print (create_character("thunde",5,3,4))
print (create_character("thunde",1,3,4))
Your browser information:
User Agent is: Mozilla/5.0 (X11; Linux x86_64; rv:140.0) Gecko/20100101 Firefox/140.0
Challenge Information:
Build an RPG Character - Build an RPG Character