Learn > BGE > Python – Turtle Graphics > 3. Fixed Loops

Fixed Loops

A fixed loop in Python Turtle Graphics is a loop that repeats a set of commands a specific number of times using for and range().

For example, for i in range(4) repeats the code 4 times, which is useful for drawing shapes like squares.

from turtle import *

screen = getscreen()
tom = Turtle()

for counter in range(4):
    tom.forward(200)
    tom.right(90)

*The lines indented under a for command are repeated.

Fixed Loop Benefits

  • Saves time
    You don’t have to write the same code again and again.
  • Good for repeating jobs
    Like counting numbers, drawing shapes, or printing words many times.
  • Keeps code neat
    Your program looks cleaner and shorter.