Skip to content
Advertisement

PYTHON TypeError: validTicTacToe() missing 1 required positional argument: ‘board’

I am new to python and trying to run this code on VScode. It gives an error saying TypeError: validTicTacToe() missing 1 required positional argument: ‘board’. What am I doing wrong here? I am actually trying to understand how does the self works. I know c++ so if you can explain in comparison to c++ it would be of great help.

Also, this is a leetcode problem, it works good on leetcode, but looks like I have to make some changes before running it on VScode. TIA

JavaScript

Advertisement

Answer

You defined your functions in the manner of object methods. These will always automatically receive their instance object as the first parameter. By convention, this parameter is named self. You however didn’t declare a class to contain these methods. You can either remove the self parameters from your functions or wrap them inside a class definition:

JavaScript

To make actual use of the class mechanism, the board should be a property:

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement