Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 why won't my turtle move
#1
import turtle
fred=turtle.Pen()
fred=turtle.shape("turtle")
fred=turtle.color("purple")
fred.forward(100)
Error:
My error message is Traceback (most recent call last): File "C:/Users/Mitesh Patel/Desktop/trash.py", line 5, in <module> fred.forward(100) AttributeError: 'NoneType' object has no attribute 'forward' >>>
What does this all mean? My turtle should be moving
Quote
#2
Try turtle.forward(100). You might also want to check out the turtle documentation.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures

Quote
#3
I did as you said, but now there is an arrow at the starting point and this is weird. Why is the computer leaving an arrow at the starting point and why is my first python commands not correct???
import turtle
fred=turtle.Pen()
fred=turtle.shape("turtle")
fred=turtle.color("purple")
turtle.forward(100)


Quote
#4
I don't know why it's drawing the arrow. It's clear that the Pen command is drawing it, but Pen with a capital p is not documented. With a lowercase p it doesn't do that, it should just return the current pen settings.

Your first command doesn't work because fred isn't a Turtle object. At the end of your program, fred is None, because that's what turtle.color returns. If you want a turtle named fred to manipulate, you need to create one with fred = turtle.Turtle(). But to move that turtle you need to send the commands to fred, as in fred.forward(100).
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures

Quote
#5
Now things are getting weird, I did do fred=turtle.Turtle(), but now a third arrow has appeared---- you have to test the program out yourself--- I always thought = means "is a", but now everything's gone weird.

import turtle
emily=turtle.Pen()
emily.shape("turtle")
emily.color("purple")
emily=turtle.Turtle()
emily.forward(100)
turtle.forward(300)
I still don't understand why my computer didn't understand my first commands on my first post---- Fred is clearly the turtle and should be moving, it is so obvious even the computer knows that fred "is a" turtle.
Quote
#6
Again, you didn't set emily to be a turtle, not until line 5. That needs to be the first thing you do. Then do all the other commands, using emily, not turtle.

import turtle
emily = turtle.Turtle()  # this is what makes emily a turtle.
emily.Pen()
emily.shape('turtle')
...
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures

Quote
#7
Thank you for your help and thank you for your patience

import turtle
emily= turtle.Turtle()
emily.shape("turtle")
emily.color("purple")
emily.forward(100)
emily.forward(200)
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  wn = turtle.screen() AttributeError: module 'turtle' has no attribute 'screen' Shadower 1 1,311 Feb-06-2019, 01:25 AM
Last Post: woooee
  Help! Turtle not working, even when we click the turtle demo in IDLE nothing happens. BertyBee 3 611 Jan-04-2019, 02:44 AM
Last Post: SheeppOSU

Forum Jump:


Users browsing this thread: 1 Guest(s)