Topic Information

python beginner by rowross in Things I'm Making and Creating

Posts: 7

1: rowross wrote at 8:00:29 AM 16/9/20204421981
Hello, im having a problem with python. Im a complete beginner and i keep getting this error in this code.

from turtle import *
shape(“turtle”)
for move in range(8):
fill()
size = 100
fd(size)
lt(360/8)

Syntax error : expected an indented block

please help?
2: imfh wrote at 1:59:27 PM 16/9/20204422582
The part of your code which makes the turtle move forwards is fd (shorthand for forward() ). Let me break down what your code does:

1. You set the appearance of your turtle. shape(“turtle”)
2. You enable pen fill. This means that the next shape drawn with the pen will be filled in and not hollow. I don't believe there is any reason to run it multiple times.
3. You set size to 100, and then move forwards size, or 100, steps.
4. You turn left by 360/8, or 45 degrees.

As you can see, you tell it to move forwards once, just like you see happen.

It might help you to check out the turtle documentation: https://docs.python.org/3/library/turtle.html

At the top of the page is a list of every function in the turtle module. If you don't know what something does, you should look it up before using it.
3: rowross wrote at 4:22:49 AM 17/9/20204424378

imfh wrote:

The part of your code which makes the turtle move forwards is fd (shorthand for forward() ). Let me break down what your code does:

1. You set the appearance of your turtle. shape(“turtle”)
2. You enable pen fill. This means that the next shape drawn with the pen will be filled in and not hollow. I don't believe there is any reason to run it multiple times.
3. You set size to 100, and then move forwards size, or 100, steps.
4. You turn left by 360/8, or 45 degrees.

As you can see, you tell it to move forwards once, just like you see happen.

It might help you to check out the turtle documentation: https://docs.python.org/3/library/turtle.html

At the top of the page is a list of every function in the turtle module. If you don't know what something does, you should look it up before using it.

okay thanks, ill try that.
4: rowross wrote at 4:25:21 AM 17/9/20204424381
hang on, in the book that i have for python tutorials, it says that “ for move in range(8): ” means that the code will repeat 8 times.
5: rowross wrote at 4:27:06 AM 17/9/20204424382
Oh, it works now! i did this code :

from turtle import *
shape(“turtle”)
begin_fill()
for move in range(8):
size = 100
fd(size)
lt(360/8)
6: imfh wrote at 3:09:17 PM 17/9/20204425237
Yep, it looks like that will work. Only the stuff indented under the for move in range will repeat 8 times.
7: rowross wrote at 11:13:03 PM 22/9/20204439879
Ah, so thats why it wasnt working before.