onclick turtle method in python 3
<p>I am re-creating the game of x and os, but I can't seem to get the onclick method in python3 to work here's my code:</p>

<pre><code>def hide(t):
    t.hideturtle()

def begin():
    global playersTurn
    if playersTurn == 0:
        playerOnesTurn.showturtle()
        playerOnesTurn.onclick(hide)
    else:
        playerTwosTurn.showturtle()
        playerTwosTurn.onclick(hide)
</code></pre>

<p>I'm displaying an image in the turtle <code>playerOnesTurn</code>and <code>playerTwosTurn</code>.
When I run the program and I want the turtle to hide when the player clicks on the image, it gives me the following error and I have not found a solution:</p>

<pre><code>TypeError: hide() takes 1 positional argument but 2 were given
</code></pre>

<p>The <code>onclick()</code> handler expects a function that takes the x &amp; y positions as arguments.  So, instead do something like:</p>

<pre><code>playerOnesTurn.onclick(lambda x, y: playerOnesTurn.hideturtle())
</code></pre>

<p>Other comments: if you're only checking <code>playersTurn</code>, not changing it, then you don't need the <code>global playersTurn</code> statement; when you enable <code>onclick()</code> for one player, you might want to disable it for the other player by doing <code>playerTwosTurn.onclick(None)</code>.</p>

python python-3.x turtle-graphics