TEST 7: I NEED help on this RPG character lesson, no matter what I’ve tried running test 7 always gives an error any help is appreciated.
Your code so far
full_dot = '●'
empty_dot = '○'
def create_character(name, strength, intelligence, charisma):
if not isinstance (name, str):
return "The character name should be a string"
if len(name) == 0:
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"
if not (isinstance(strength,int) or isinstance(intelligence, int) or isinstance(charisma, int)):
return "All stats should be integers"
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36
I guess you are trying to use not to negate all of (isinstance(strength,int) or isinstance(intelligence, int) or isinstance(charisma, int) right?
you also have an extra ) at the end that would give an error
instead the expression is read like ( not (isinstance(strength,int) ) or isinstance(intelligence, int) or isinstance(charisma, int)
Right, i guess i’m using the [not] to negate if any stat checks as not being an integer. However taking out the extra parenthesis also isn’t valid. Here’s my fresher code…
if not isinstance(strength, int) or isinstance(intelligence, int) or isinstance(charisma, int):
Well… I went to separate all 3 expressions (i’m not comfortable with using [all] just yet) and it won’t pass the test
if not isinstance(strength,int):
return "All stats should be integers"
if not isinstance(intelligence, int):
return "All stats should be integers"
if not isinstance(charisma, int):
return "All stats should be integers"