How to stop turtle from drawing even with pen up?

30,044

Solution 1

It looks like you're not actually calling turtle.penup. Try this:

import turtle

turtle.penup()
turtle.goto(0,50)

Solution 2

You have a typo, you aren't calling the penup method:

import turtle

turtle.penup() #This needs to be a method call
turtle.goto(0,50)

Solution 3

This question is super old and definitely has already been answered, but I'll leave this explanation here for future people

"penup" is a method in Python, aka function in other languages. This means that when you want to use it you have it include some parenthesis just so that your code knows what is supposed to be happening

import turtle

turtle.penup()
turtle.goto(0,50)

When you don't include the parenthesis, the code thinks you are talking about a variable, and looks for one called "penup", but there is no variable of that name, so Python throws its hands up and crashes

Share:
30,044
derpyherp
Author by

derpyherp

Updated on July 05, 2022

Comments

  • derpyherp
    derpyherp almost 2 years

    I am using the turtle module in python. the problem is that whenever I have the turtle move i will draw even if the pen is up. for example if I run this program:

    import turtle
    
    turtle.penup
    turtle.goto(0,50)
    

    the turtle will still draw a line when it moves to (0,50) why is this and how can it be prevented?

  • Jason Aller
    Jason Aller about 4 years
    If the intent was to convey that they need to add () after penup to turn it into a function call that should be stated in an explanation that goes with the code. This is also a seven year old question with existing answers that already covered that aspect of the question.