how to use goto in python turtle 1

how to use goto in python turtle

#Draw a set of nested squares, increasing in size
from turtle import *

number_of_shapes = 4

for shape in range(1, number_of_shapes + 1):
    #Draw a square
    for sides in range(1,5):
        forward(20 + shape * 10)

#Move to position of next square
    goto(shape * 10, shape * 10)

Here is what the above code is Doing:
1. The outer for loop is looping through the number of shapes we want to draw.
2. The inner for loop is drawing the square.
3. The penup() and pendown() functions are used to move the turtle to the position of the next square.

Similar Posts