generated from mwc/lab_iteration
I removed the extra forwards and rights, created a new temporarily assigned variable called sides and juts put numbers 1 through 4 in it as the numbers dont matter since i have assigned values for my forward and right already.
At first I was a little confused on if i had to edit the existing for loop and if so how, so i took a second to run the existing code to see that i dont need to change the existing for loop as that just makes the square run 4 times, i realized i need to make a new for loop inside of square. That was really my only struggle.
This commit is contained in:
12
square.py
12
square.py
@@ -1,15 +1,13 @@
|
||||
from turtle import *
|
||||
|
||||
sides = [1,2,3,4]
|
||||
def square(side_length):
|
||||
forward(side_length)
|
||||
right(90)
|
||||
forward(side_length)
|
||||
right(90)
|
||||
forward(side_length)
|
||||
right(90)
|
||||
forward(side_length)
|
||||
for side in sides:
|
||||
forward(20)
|
||||
right(90)
|
||||
|
||||
|
||||
|
||||
sizes = [20, 40, 60, 80, 100]
|
||||
for size in sizes:
|
||||
square(size)
|
||||
|
||||
Reference in New Issue
Block a user