Reputation: 11
My code in python:
import turtle
arikany = turtle.turtle()
arikany.bgcolor("black")
arikany.pensize(2)
arikany.speed(0)
for i in range (20):
for colours in ["red","magenta","cyan","yellow","grey"]:
arikany.color(colours)
arikany.circle(100)
arikany.left(100)
arikany.forward(95)
arikany.right(345)
arikany.backward(58)
turtle.done()
The code gives me the error:
Traceback (most recent call last):
File "F:/py/spirograph.py", line 5, in <module>
arikany = turtle.turtle()
AttributeError: module 'turtle' has no attribute 'turtle'
Upvotes: 0
Views: 2710
Reputation: 31
Above all, check if you have done the common mistake of naming your file as turtle.py
if you do so, it imports your file and not the actual turtle library. So rename your file and check. If it doesn't work, other technical corrections suggested previous messages need to be checked. :)
Upvotes: 0
Reputation: 1
You should always focus at capitalisation of the words: arikany = turtle.Turtle
So,you are making an instance of the class Turtle,which is located inside of the module turtle. And the first letter of every word in a class is always in capital case
Upvotes: 0
Reputation: 1042
You are trying to create an Instance of the class Turtle from the module turtle. Capitalization is crucial in this case.
The line should be something like this:
arikany = turtle.Turtle()
ps.: Its generally preferable in python3 to use the syntax from turtle import Turtle
in order to explicitely import what you need.
Your line would then look like this:
arikany = Turtle()
Upvotes: 1