Python hexa spiral issue
import turtle
t=turtle.pen ()
turtle.bgcolor (‘black’)
for x in range (360):
t.pencolor (colors[x%6])
t.left (59)
The above code is problem.when I try to run.I don’t understand. Please help

1 Like

Thank you for reply sir.but I can’t understand your language

I see two problems:

  1. You define colours and then reference colors. One of those must be a typo.
  2. turtle.pen() does not return an object. I assume you mean the Turtle (which has capital Pen as an alias). You should use t = turtle.Turtle() instead.

When asking about code problems in the future please describe exactly what is going on, not just “problem”, and any error messages you’re getting. It’s much easier to help that way. :wink:


I am using "qpython ".it’s show an indentation is missing. Where ?

That’s impossible to answer without seeing your code, but the error message should tell you the affected line.

There’s a basic description of indentation rules here (third point in section 3.2):

1 Like

Please check my codes

That message says that turtle.Pen is not a valid name. So whatever you use is not compatible with regular Python. Maybe an outdated version?

Try using turtle.Turtle instead, as I mentioned above the Pen is simply an alias for that. If that doesn’t help you’ll need to look into getting a current Python version, or find documentation on whatever variant you’re using to see how they modified the API.

1 Like

I try everything but not working in "qpython "app.Attribute issue.I am non programming background student

qpython is likely to be your problem. Try using “python” or “python3” instead. I doubt the “turtle” library is available in qpython.

You need to type the real program, letter by letter. For instance your copy is missing the spaces at the beginning of lines 7 through 10.

1 Like