Tell us what’s happening:
Describe your issue in detail here.
no matter how I try the code does n’t want to run
Your code so far
full_dot = '●'
empty_dot = '○'
# 2. Use lowercase 'def' keyword
def create_character(name, strength, intelligence, charisma):
# 1. Name Validations
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.'
# 2. Stat Type Validation
if not isinstance(strength, int) or not isinstance(intelligence, int) or not isinstance(charisma, int):
return 'All stats should be integers.'
# Ensure boolean values aren't passed (in Python, bool is a subclass of int)
if type(strength) is bool or type(intelligence) is bool or type(charisma) is bool:
return 'All stats should be integers.'
# 3. Stat Range Validations
if strength < 1 or intelligence < 1 or charisma < 1:
return 'All stats should be no less than 1.'
if strength > 4 or intelligence > 4 or charisma > 4:
return 'All stats should be no more than 4.'
# 4. Total Points Validation
if strength + intelligence + charisma != 7:
return 'The character should start with 7 points.'
# 5. Build String Output
str_dots = full_dot * strength + empty_dot * (10 - strength)
int_dots = full_dot * intelligence + empty_dot * (10 - intelligence)
cha_dots = full_dot * charisma + empty_dot * (10 - charisma)
return f'{name}\nSTR {str_dots}\nINT {int_dots}\nCHA {cha_dots}'
Your mobile information:
XBOOK_12 - Android 14 - Android SDK 34
Challenge: Build an RPG Character - Build an RPG Character
Link to the challenge: