Python Forum

Full Version: python turtle module in pycharm error
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
hi guys  

import turtle
def draw_star(size,color):
    count = 0
    angle = 144
    sum1 = 0
   # turtle.bgcolor='black'
    turtle.bgcolor = 'black'
    turtle.pen='yellow'
    while count <= 5:
        for i in (1,5):
            sum1=sum1+45
            if count<5:
                turtle.forward(sum1)
                turtle.right(angle)
            if count>5:
                turtle.forward (-size)
                turtle.right (angle)
        count += 1
    return

draw_star(200,"blue")
This code run in python idle without error. but pycharms cant run this code  Think    

pycharm error:

Traceback (most recent call last):
  File "C:/Users/3DVFX/PycharmProjects/untitled4/turtle.py", line 1, in <module>
    import turtle
  File "C:\Users\3DVFX\PycharmProjects\untitled4\turtle.py", line 21, in <module>
    draw_star(200,"blue")
  File "C:\Users\3DVFX\PycharmProjects\untitled4\turtle.py", line 13, in draw_star
    turtle.forward(sum1)
AttributeError: module 'turtle' has no attribute 'forward'
Rename turtle.py.
Name is used in bye python to run the module eg ‪C:\Python35\Lib\turtle.py
(Dec-12-2016, 08:14 PM)snippsat Wrote: [ -> ]Rename turtle.py.
Name is used in bye python to run the module eg ‪C:\Python35\Lib\turtle.py

i rename turtle.py to myturtle.py    Tongue Clap

Thankyou