Turtle window not closing

Harshika Varadhan hsvaradhan at yahoo.com
Fri Apr 21 21:22:34 EDT 2017


Hi everyone,
I am creating a game where the user inputs a coordinate to place their piece on a chess board. My code then draws the chess board with a turtle and fills in the squares in with green where the user can place their next piece. After the user inputs their first coordinate, the turtle draws the board, but then the window doesn't close and the program ends up crashing. Is there any way to solve this problem?I appreciate your help.
My function for drawing the chess board:
def draw_board():    t = turtle.Turtle()    t.speed(0)    t.ht()    t.up()    t.goto(-100, -100)    t.down()
    for i in range(0, 8):        for j in range(0, 8):            if free_squares[i][j] == ".":                if j != 7:                    t.fillcolor("green")                    t.pencolor("black")                    t.begin_fill()                    for k in range(4):                        t.forward(50)                        t.left(90)                    t.end_fill()                    t.forward(50)                if j == 7:                    t.fillcolor("green")                    t.pencolor("black")                    t.begin_fill()                    for k in range(4):                        t.forward(50)                        t.left(90)                    t.end_fill()                    t.right(270)                    t.forward(50)                    t.left(90)                    t.forward(350)                    t.right(180)
    turtle.bye()
Thank you, Harshi


More information about the Python-list mailing list