Tell us what’s happening:
I am running into an issue where my code doesn’t pass test 2: “When create_character is called with a first argument that is not a string it should return The character name should be a string.” I have tried a few variants of the if statement that references this condition, which didn’t work, and when I reviewed the forum, I see that other code with the same statement has passed this test. I’m pretty lost as to what to do here. Can anyone help?
Your code so far
full_dot = '●'
empty_dot = '○'
def create_character(name, strength, intelligence, charisma):
if not isinstance(name, str):
return print("The character name should be a string")
elif name == '':
return print('The character should have a name')
elif len(name) > 10:
return print('The character name is too long')
elif not isinstance(strength, int) or not isinstance(intelligence, int) or not isinstance(charisma, int):
return print('All stats should be integers')
elif strength > 4 or intelligence > 4 or charisma > 4:
return print('All stats should be no more than 4')
elif strength + intelligence + charisma != 7:
return print('The character should start with 7 points')
else:
return print(
f'{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}'
)
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/146.0.0.0 Safari/537.36
Challenge Information:
Build an RPG Character - Build an RPG Character