why won't my turtle move - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: why won't my turtle move (/thread-14056.html) |
why won't my turtle move - ironsheep - Nov-13-2018 import turtle fred=turtle.Pen() fred=turtle.shape("turtle") fred=turtle.color("purple") fred.forward(100) What does this all mean? My turtle should be moving
RE: why won't my turtle move - ichabod801 - Nov-13-2018 Try turtle.forward(100) . You might also want to check out the turtle documentation.
RE: why won't my turtle move - ironsheep - Nov-13-2018 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) RE: why won't my turtle move - ichabod801 - Nov-13-2018 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) .
RE: why won't my turtle move - ironsheep - Nov-14-2018 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. RE: why won't my turtle move - ichabod801 - Nov-14-2018 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') ... RE: why won't my turtle move - ironsheep - Nov-15-2018 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) |