Rewrote square function using iteration.

- No, the wording of the lab was a little confusing because it says to use
list iteration but you don't actually need a list for it. Also, the function
still "calls" forward and right four times; we only wrote it once.
This commit is contained in:
tgaeta
2025-09-15 13:21:18 -04:00
parent ab8de63b67
commit 19d67c8363

View File

@@ -1,14 +1,9 @@
from turtle import * from turtle import *
def square(side_length): def square(side_length):
forward(side_length) for _ in range(4):
right(90) 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: