Dec-01-2017, 04:51 AM
Question - "Write code that draws a pattern with the turtle with at least 3 different colors used. The code must have a for loop and must have a if statement inside the for loop that changes the color."
In the below I can make it happen if I write out each step on line beneath color change. I am trying to be more efficient and use a procedure - but procedure does not execute. No errors, just turtle doesn't move. Thank you for any advice.
In the below I can make it happen if I write out each step on line beneath color change. I am trying to be more efficient and use a procedure - but procedure does not execute. No errors, just turtle doesn't move. Thank you for any advice.
from turtle import *
from sys import *
setExecutionLimit(30000)
space = Screen()
width = 400
space.setup(width,width)
maxX = width / 2
jazze = Turtle()
jazze.shape('turtle')
jazze.penup()
jazze.pensize(3)
def drawLine():
jazze.goto(-1 * maxX,x * 10)
jazze.pendown()
jazze.forward(width)
for x in range(10):
if x % 3 == 0:
jazze.color('red')
drawLine
elif x % 3 == 1:
jazze.color('black')
drawLine
elif x % 3 == 2:
jazze.color('green')
drawLine
