While our turtle move program looks good, we can make a few improvements.There are two things we can fix:
• Firstly, there's quite a bit of repeated code
• Secondly, the thin black line looks a little drab.
So, let's edit the code as shown in the listing below:
from turtle import *
for i in range(4):
Save the code and run the program to discover what happens now. See the difference?
After the import statement we've added the
pensize commands. These settings will cause our turtle to draw a thick blue line.
More importantly, we've put the movement commands into a
for loop. This loop repeats the
right commands four times - a much neater coding solution.
A post from my Learn Python on the Raspberry Pi tutorial.