I am trying to make a hirst painting (dot pattern) using the turtle in python. I managed to achieve it. Hirst_painting_dot_pattern.But my for loop isn’t working the way I have expected. It’s omitting the last iteration.
In the code below, my for loop isn’t making the last dot. So, I have added one more line at the end of the loop to make the last dot. But I don’t understand why the last dot is not drawn, though its within the range. Can somebody explain me?
import turtle as t
import random
tim = t.Turtle()
screen = t.Screen()
color_list = [(202, 164, 110), (240, 245, 241), (236, 239, 243), (149, 75, 50), (222, 201, 136), (53, 93, 123), (170, 154, 41), (138, 31, 20), (134, 163, 184), (197, 92, 73), (47, 121, 86), (73, 43, 35), (145, 178, 149), (14, 98, 70), (232, 176, 165), (160, 142, 158), (54, 45, 50), (101, 75, 77), (183, 205, 171), (36, 60, 74), (19, 86, 89), (82, 148, 129), (147, 17, 19), (27, 68, 102), (12, 70, 64), (107, 127, 153), (176, 192, 208), (168, 99, 102)]
t.colormode(255)
tim.speed("fastest")
tim.penup()
tim.setpos(-200, -200)
tim.pendown()
x = -200
y = -200
for yax in range(10):
for xax in range(10):
tim.pendown()
tim.dot(20, random.choice(color_list))
tim.penup()
tim.setpos(x, y)
x += 50
y += 50
x = -200
tim.dot(20, random.choice(color_list))
tim.hideturtle()
screen.exitonclick()
Savi K is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.