Problem with indention in python turtle


#1

For some reason, it keeps on saying that my indention is incorrect.

The code was simple. Basically:

import turtle
t = turtle.Pen()

for x in range(100):

 t.forward(4*x)

 t.left(90)

When I pressed enter, there was automatic indention, so I did not use space/tab. But when I try to run it, the indention is somehow incorrect. I tried to delete do the indention again and again but it never worked for some reason.

How can I fix this problem…?


#2

Hi @onlysmartpeoplecanse

Some of the indentation in your posted code is not visible.

If this line is indented in the actual code that you submitted to the Python interpreter, it would raise an IndentationError

t = turtle.Pen()

These two lines do need to be indented …

 t.forward(4*x)

 t.left(90)

Be sure to use either spaces or tabs for the indentation, but not both in the same program.


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.