Why do I get this unexpected syntax error on the Python console?
This behavior is intended and is how Python knows you intend to terminate a loop. You have to end the for block, by pressing Enter on an empty line, before writing anything outside it.

Oppose:

&gt;&gt;&gt; f = []
&gt;&gt;&gt; for p in bpy.context.scene.objects['Torus'].data.polygons:
...     f.append(p.index)
... print(f) #Notice how this line starts with an ellipsis


With:

&gt;&gt;&gt; f = []
&gt;&gt;&gt; for p in bpy.context.scene.objects['Torus'].data.polygons:
...     f.append(p.index) #Hit enter _twice_ after this line
...
&gt;&gt;&gt; print(f) #Notice how this line starts with three greater than symbols




Note that this isn't specific to Blender, the same behavior can be found in Python's default console - just by running "python" from the command line.