generated from mwc/lab_iteration
changed square.py to use list iteration, ck #1
I thought the directions were very clear for the list iteration although I did need to read through them several times, and tried to understand what they were saying before opening the file. I then ran the original code to see what it did, so I could compare my final product. As I worked on the list iteration, I also kept the original code at top commented out so I could refer to it, and did not delete it until I was sure my iteration method worked. I was not totally sure if I could call the list whatever I wanted to, but it seems like I could as long as one of the names is singular and the other is plural. I feel like I have a good grasp of iteration after this part.
This commit is contained in:
parent
883e64b8de
commit
29b250ff83
11
square.py
11
square.py
|
@ -1,12 +1,11 @@
|
||||||
from turtle import *
|
from turtle import *
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def square(side_length):
|
def square(side_length):
|
||||||
forward(side_length)
|
sides = [1,2,3,4]
|
||||||
right(90)
|
|
||||||
forward(side_length)
|
for side in sides:
|
||||||
right(90)
|
|
||||||
forward(side_length)
|
|
||||||
right(90)
|
|
||||||
forward(side_length)
|
forward(side_length)
|
||||||
right(90)
|
right(90)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue