help with python

the images attached are the instructions, but i have been on this for days with no luck, therefore I have attached my own code as well.

import turtle

import random

z = turtle.Turtle() #global

global window

window = turtle.Screen()

dice = []

buttons = []

def drawCenterDot(z, x, y, width, dotwidth):

    z.penup()

    z.goto(x + width / 2, y – width / 2)

    z.pendown()

    z.dot(dotwidth)

def drawCornerDots(z, x, y, width, dotwidth):

    z.penup()

    z.goto(x + dotwidth, y – dotwidth)

    z.pendown()

    z.dot(dotwidth)

    z.penup()

    z.goto(x + width – dotwidth, y – width + dotwidth)

    z.pendown()

    z.dot(dotwidth)

    

def drawOtherCornerDots(z, x, y, width, dotwidth):

    z.penup()

    z.goto(x + width – dotwidth, y – dotwidth)

    z.pendown()

    z.dot(dotwidth)

    z.penup()

    z.goto(x + dotwidth, y – width + dotwidth)

    z.pendown()

    z.dot(dotwidth)

def drawSideDots(z, x, y, width, dotwidth):    

    z.penup()

    z.goto(x + dotwidth, y – width / 2)

    z.pendown()

    z.dot(dotwidth)

    z.penup()

    z.goto(x + width – dotwidth, y – width / 2)

    z.pendown()

    z.dot(dotwidth)

#Defined drawing some spicy dots 😉 

def drawDots(z, dieValue, x, y, width):

    dotwidth = width // 6

    if dieValue == 1:

        drawCenterDot(z, x, y, width, dotwidth)

    elif dieValue == 2:

        drawCornerDots(z, x, y, width, dotwidth)

    elif dieValue == 3:

        drawCenterDot(z, x, y, width, dotwidth)

        drawOtherCornerDots(z, x, y, width, dotwidth)

    elif dieValue == 4:

        drawCornerDots(z, x, y, width, dotwidth)

        drawOtherCornerDots(z, x, y, width, dotwidth)

    

    elif dieValue == 5:

        drawCenterDot(z, x, y, width, dotwidth)

        drawCornerDots(z, x, y, width, dotwidth)

        drawOtherCornerDots(z, x, y, width, dotwidth)

    

    else:

        drawCornerDots(z, x, y, width, dotwidth)

        drawOtherCornerDots(z, x, y, width, dotwidth)

        drawSideDots(z, x, y, width, dotwidth)

def drawDie(z, value, x, y, width, color=’white’):

    z.penup()

    z.goto(x, y)

    z.setheading(0)

    z.fillcolor(color)

    

    z.pendown()

    z.begin_fill()

    for _ in range(4):

        z.forward(width)

        z.right(90)

    

    z.end_fill()

    z.penup()

    drawDots(z, value, x, y, width)

def mouseClick(x,y):

    global dice

    global buttons

    print(“mouse clicked at position ” +str(x) + “,” + str(y))

    

    for button in buttons:

        count = 0

        if isWithin(x, y,button[0],button[1],button[2],button[3]) == True:

            buttonClick(count)

        else:

            count+=1

    for die in dice:

        count = 0

        if isWithin(x,y,die[1],dice[2],dice[3],dice[4]) == True:

            dieClick(count)

        else:

            count+=1

def isWithin(x, y, a, b, width, height):

    if a < x < a + width and b – height < y < b:

        return True

    else:

        return False

def buttonClick(index):

    global dice

    global z

    global buttons

    if index == 0:

        for die in dice:

            die[4] = “white”

    for die in dice:

        if die[4] == “white”:

            die[0] == random.randint(1,6)

def dieClick(index):

    global dice

    global z

    if dice[index][4] == “white”:

        dice[index][4] = “blue”

    else:

        dice[index][4] == “white”

    return drawDie(z, dice[index][0],dice[index][1],dice[index][2],dice[index][3],dice[index][4])

    

def drawRectangle(z, x, y, width, height, line_color,fill_color, Text = “None”):

    z.penup()

    z.goto(x,y)

    z.pencolor(line_color)

    z.fillcolor(fill_color)

    z.pendown()

    z.begin_fill()

    z.setheading(0)

    z.forward(width)

    z.right(90)

    z.forward(width)

    z.right(90)

    z.forward(width)

    z.right(90)

    z.forward(width)

    z.right(90)

    z.end_fill()

    z.penup()

def main():

    global dice

    global buttons

    global z

    global window

    window.bgcolor(“LightPink”)

    window = turtle.Screen()

    z = turtle.speed(0)

    turtle.hideturtle()

    width = 1000

    height = 800

    

    window.onclick(mouseClick, 1, True)

    window.onclick(buttonClick,1, True)

    turtle.mainloop()

    

    

    dice = dice + [random.randint(1,7)]

    return dice

main()