Back to Freecodecamp

Step 8

curriculum/challenges/english/blocks/learn-classes-and-objects-by-building-a-sudoku-solver/66069b992c1c5e3451f3deb0.md

latest1.1 KB
Original Source

--description--

The instantiation creates an empty object. The __init__ method is a special method that allows you to instantiate an object to a customized state. When a class implements an __init__ method, __init__ is automatically called upon instantiation.

Inside your Board class, delete the spam method and replace it with an __init__ method that includes a self parameter.

--hints--

You should not have a spam method in your Board class.

js
({ test: () => assert.isFalse(runPython(`_Node(_code).find_class("Board").has_function("spam")`)) })

You should define an __init__ method in your Board class.

js
({ test: () => assert(runPython(`_Node(_code).find_class("Board").has_function("__init__")`)) })

Your __init__ method should have a self parameter.

js
({ test: () => assert(runPython(`_Node(_code).find_class("Board").find_function("__init__").has_args("self")`)) })

--seed--

--seed-contents--

py
--fcc-editable-region--
class Board:
    def spam(self):
        print('Spam!')
    
gameboard = Board()
--fcc-editable-region--