from turtle import Screen, Turtle
screen = Screen()
screen.setup(width=600, height=600)
screen.bgcolor("black")
screen.title("My Snake Game")
screen.tracer(0)
starting_positions = [(0, 0), (-20, 0), (-40, 0)]
segments = []
for position in starting_positions:
new_segment = Turtle("square")
new_segment.penup()
new_segment.color("white")
new_segment.goto(position)
segments.append(new_segment)
game_is_on = True
while game_is_on:
for seg in segments:
seg.forward(20)
screen.exitonclick()
When I execute the above code it is giving: output
Please, can someone tell me why is this happening and the solution to this problem?