full_dot = ‘●’
empty_dot = ‘○’
>
def create_character(character_name,strength,intelligence,charisma):
#Checks for character name
if not isinstance(character_name,str):
return “The character name should be a string”
elif not character_name:
return “The character should have a name”
elif len(character_name) > 10:
return “The character name is too long”
elif not character_name.find(" ") == -1:
return “The character name should not contain spaces”
>
#Strength Check
if not isinstance(strength,int):
return “All stats should be integers”
elif strength < 1:
return “All stats should be no less than 1”
elif strength > 4:
return “All stats should be no more than 4”
>
#Intelligence Check
if not isinstance(intelligence,int):
return “All stats should be integers”
elif intelligence < 1:
return “All stats should be no less than 1”
elif intelligence > 4:
return “All stats should be no more than 4”
>
#Charisma Check
if not isinstance(charisma,int):
return “All stats should be integers”
elif charisma < 1:
return “All stats should be no less than 1”
elif charisma > 4:
return “All stats should be no more than 4”
>
if not (charisma + strength + intelligence) == 7:
return "The character should start with 7 points"
return character_name + "\nSTR:",(strength * full_dot +((10 - strength) * empty_dot)) + "\nINT:",(intelligence * full_dot +((10 - intelligence) * empty_dot)) + "\nCHA:",(charisma * full_dot +((10 - charisma) * empty_dot))
>
print(“Working!”)
>
create_character(“Leroy”,9,20,30,)
I am unsatisfied with the solution of making new variable for the final output of the program, but I don’t want solutions more advance than my current position in the course. I tried a method that I feel was alittle logical but it isn’t working.
Hoping for an alternative method and reason why my previous return didn’t work.
Example of code, I am trying to avoid:
STR *dots = 10 - STR
True_*STR = STR x dot + STR_dots x empty dots
print True_STR#Repeat for other variables