2

I have the following code to play with turtle within turtleworld:

>>> from swampy.TurtleWorld import *
>>> world = TurtleWorld()
>>> bob = Turtle()
>>> fd(bob, 100)
>>> bob.position()
>>> bob.reset()

There is no issue with executing the fd(bob, 100) line but when I try to check turtle position it returns AttributeError:

Traceback (most recent call last):
  File "<pyshell#13>", line 1, in <module>
    bob.position()
AttributeError: 'Turtle' object has no attribute 'position'

Why is this happening? What am I missing? I have read the documentation and it states that both position() and reset() methods should be available.

2
  • 1
    I'm not familiar with this library, but it looks like there is no such attribute indeed: github.com/AllenDowney/Swampy/blob/master/python3/… Commented May 6, 2018 at 11:38
  • Thank you. As stated below by HKJeffer I have mixed turtle module with swampy.TurtleWorld's Turtle class. Thank you for the link, I need to read it. Commented May 6, 2018 at 12:10

1 Answer 1

1

You may be mixing up the turtle module with swampy.TurtleWorld's Turtle class.

In the turtle module, there is indeed a position() method, however there isn't in swampy.TurtleWorld's Turtle class, as mentioned by @Georgy in the comments.

You can instead use bob.get_x() and bob.get_y() for its x, y coordinates.

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

1 Comment

Thank you, I just got lost at the beginning of my adventure with Python. It seems too many turtles around ;)

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.