Learn Classes and Objects by Building a Sudoku Solver - Step 6

Tell us what’s happening:

I am trying to call the spam method of the gameboard object to my code. Right now I have gameboard.spam() but it is not returning as correct and I am confused. Thanks!

These are the instructions:
To call an instance method, you need to use dot notation:

Example Code

instance_name.method_name()

Where instance_name is the instance or object, and method_name is the method you want to call.

Call the spam method of the gameboard object.

Your code so far


# User Editable Region

class Board:
    def spam(self):
        print('Spam!')
        gameboard.spam()
gameboard = Board()

# User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36

Challenge Information:

Learn Classes and Objects by Building a Sudoku Solver - Step 6

You need to do things in this order:

  1. define the class (Board)
  2. Instantiate the class (gameboard)
  3. call the method of the instantiation

You are calling the method of the gameboard object inside the definition of the class. You need to do this outside the class, after instantiating gameboard.

Thank you, don’t know why I didn’t think of that.

1 Like