This code makes Turtle draw a square. There is a pattern. Do you see the pattern? Move forward 75 pixels, then turn to the left at 90 degrees (1/4 turn), and do that 4 times. Walk it on the floor only 3 steps, not 75 pixels!
If you want to copy & paste it, here it is!:
forward(75)
left(90)
forward(75)
left(90)
forward(75)
left(90)
forward(75)
left(90)
Whenever you see a pattern, you can probably use a repeat loop. So instead of forward, left, forward, left, forward, left, forward, left... I can code "forward, left, and do those two command 4 times total!"
When using repeat loops in Python, all the code that is being repeated MUST be indented - see how the word "for" is lined up on the left side near the line numbers? And the two lines of code below it actually start under the "i"? To indent code lines, use the "Tab" key, then type or paste your code.
for i in range(4):
forward(75)
left(90)
Did you know you can put a repeat loop inside of a repeat loop? This is called "nesting".
When Turtle draws a square, then turns 36 degrees, then repeats the square, turn36, square, 36, etc. it makes a cool design!
Give it a try yourself.
speed(0)
for i in range(10):
for i in range(4):
forward(75)
left(90)
left(36)
try changing the 36 degree turn to something smaller, or larger (between 3 and 180)
you may also need to change the number of times it repeats from 10 to something larger or smaller
try changing the forward pixels to a different length up to 200.
speed(0)
for i in range(40):
for i in range(4):
forward(150)
left(90)
left(10)