0

I am just beginner with python and have started with python 2.7.3 Version.I have been following up with Think Python e-book.I am stuck at chapter 4 Case study: interface design where there is a program to draw lines.I get the following error when i run the given code.

> Execution:

C:\Users\dell\Desktop>python first.py
<swampy.TurtleWorld.Turtle object at 0x017A1650> 
Traceback (most recent call last):
  File "first.py", line 7, in <module>
    fd(bob,100)
  File "C:\Python27\lib\site-packages\swampy\TurtleWorld.py", line 186, in fd
    self.world.canvas.line([p1, p2], fill=self.pen_color)
AttributeError: 'NoneType' object has no attribute 'canvas'`

> Script

from swampy.TurtleWorld import *
world=TurtleWorld
bob=Turtle()
print bob
fd(bob,100)
lt(bob)
fd(bob,100)
wait_for_user()
Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
Kworks
  • 773
  • 4
  • 13
  • 19
  • possible duplicate of [Python : AttributeError: 'NoneType' object has no attribute 'append'](http://stackoverflow.com/questions/12715198/python-attributeerror-nonetype-object-has-no-attribute-append) – UpAndAdam Sep 11 '13 at 16:01

1 Answers1

6

You forgot to instantiate your TurtleWorld:

world = TurtleWorld()
                   ↑ these were missing
Pavel Anossov
  • 60,842
  • 14
  • 151
  • 124