[Tutor] Turtle color question
Roger Lea Scherer
rls4jc at gmail.com
Thu Mar 29 14:34:27 EDT 2018
I've tried everything I can think of but cannot get the pencolor to change.
(Although the arrow drawing the boxes changes color.) I've placed it in
places I didn't even think it would work. The arrow draws what looks like
the boxes I expect, but the color looks the same as the background. So I
assigned a variable and printed that variable which says None. See:
RESTART: C:/Users/Roger/AppData/Local/Programs/Python/Python36/turtle
square draw.py
None
>>>
Removing " color = " doesn't change the outcome. I hope this adequately
explains things.Thanks, again.
import turtle
def drawSquare(t, sz):
"""Get turtle t to draw a square of sz side"""
t.pu()
t.forward(sz*2)
for i in range(4):
t.forward(sz)
t.left(90)
wn = turtle.Screen()
wn.bgcolor("blue")
alex = turtle.Turtle()
color = alex.pencolor("darkgreen")
print(color)
def main():
for i in range(4):
drawSquare(alex,20)
main()
wn.exitonclick()
--
Roger Lea Scherer
623.255.7719
More information about the Tutor
mailing list