I am stuck on step 4, where if one or more stats are less than 1, the code returns “all stats should be no less than 1”. I am not sure how to format the “or more” part. I have used OR statements and it works that when one of the stats is less than 1, the function returns the statement. But if all stats are above 1 it still returns “all stats should be no less than 1”.
Your code so far
full_dot = '●'
empty_dot = '○'
character_name = 'Sunny'
strength = 2
intelligence = 2
charisma = 2
def create_character(character_name, strength, intelligence, charisma):
if not isinstance(character_name,str):
return('The character name should be a string')
if character_name == '':
return('The character should have a name')
if len(character_name) >10:
return('The character name is too long')
if " " in character_name:
return('The character name should not contain spaces')
if not isinstance(strength, int) or not isinstance(intelligence,int) or not isinstance(charisma,int):
return('All stats should be integers')
if strength or intelligence or charisma <1:
return('All stats should be no less than 1')
if strength or intelligence or chairsma >4:
return('All stats should be no more than 4')
if sum(strength, intelligence, charisma) != 7:
return('The character should start with 7 points')
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36
I tried putting a <1 before each stat, but that didn’t end up working when I did the same thing for the next step (If one or more stats are more than 4, the function should return All stats should be no more than 4.) Could you give me a hint as to what to change?
Sorry, I am not sure how to upload my code directly. I tried copying and pasting it in a comment but the indents were not as clear on here as there are in the activity. Here are a couple of screenshots of the error messages I got: