0

I'm trying to run this turtle function:

from turtle import *

def main():


    color('red', 'yellow')
    begin_fill()
    while True:
        forward(200)
        left(170)
        if abs(pos()) < 1:
            break
    end_fill()
    done()

main()

But I keep getting this error:

 Traceback (most recent call last):
File "C:\Users\eardery\Desktop\Final Exam Practice\turtlepolygon.py", line 1, in <module>
 from turtle import *
File "C:\Users\eardery\Desktop\Final Exam Practice\turtle.py", line 234
raise Error, "no color arguments"
           ^
SyntaxError: invalid syntax

I have no idea what this means.

1 Answer 1

1

you have a file named turtle.py in the same folder ... you should not name files the same as libraries ... you are importing from your local turtle.py file

rename turtle.py (in this same folder) to myturtle.py and it should be fine

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you it works now! I thought it had to be named turtle.py in order for Python to know which file I'm asking for. So is turtle just automatically assumed by Python in the same way as math when you import it?
@GooseLaMoose turtle.py is a file that exists in your python library. When you do import turtle, Python looks for a file called turtle.py in your local directory first, then in the python library. Because you had one named turtle.py in your local directory, it loaded that first. Renaming it to myturtle.py solves this be not "shadowing" the turtle.py in the library.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.