[Tutor] turtle question

Peter Otten __peter__ at web.de
Wed May 17 04:10:19 EDT 2017


Grace Sanford wrote:

> how do you reset the turtle's position without drawing a line from where
> it last was?

Call turtle.penup() when you want to prevent it from drawing and pendown() 
to have it draw again. Example:

import turtle

for i in range(10):
    # draw a 20 units line
    turtle.forward(20)

    # lift the pen
    turtle.penup()

    # move 10 units forward without drawing
    turtle.forward(10)

    # put the pen back on the paper
    turtle.pendown()

turtle.mainloop()




More information about the Tutor mailing list