Made the square repeat using a list iteration

It wasnt difficult, it just took some time to figure out how to write it. I used the previous code for how they repeated the square but changed its size to understand how to write the correct code.
This commit is contained in:
tsmith37
2025-09-13 21:07:58 -04:00
parent 10edd5649d
commit 034481f2a5

View File

@@ -1,17 +1,17 @@
from turtle import * from turtle import *
def square(side_length): def square(side_length):
forward(side_length) repeat = [1, 2, 3, 4]
right(90) for repeat in repeat:
forward(side_length) forward(side_length)
right(90) right(90)
forward(side_length)
right(90)
forward(side_length)
right(90)
sizes = [20, 40, 60, 80, 100] sizes = [20, 40, 60, 80, 100]
for size in sizes: for size in sizes:
square(size) square(20)
penup()
forward(40)
pendown()
input() input()