generated from mwc/lab_iteration
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:
@@ -1,12 +1,7 @@
|
|||||||
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)
|
|
||||||
right(90)
|
|
||||||
forward(side_length)
|
|
||||||
right(90)
|
|
||||||
forward(side_length)
|
forward(side_length)
|
||||||
right(90)
|
right(90)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user