Build an RPG Character - Build an RPG Character TEST 7

Tell us what’s happening:

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

Challenge Information:

Build an RPG Character - Build an RPG Character

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):

not is only acting on your first expression. You have 3 expressions separated by or here:

  1. not isinstance(strength, int)
  2. isinstance(intelligence, int)
  3. 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"

Don’t run the tests until you’ve tested your app and it works. Do each of those statements work when you do a test call to your function?

What did you do to investigate?

Do you have an error in the console?

I’ll keep working on it thanks

1 Like