derpyherp
derpyherp

Reputation: 525

How to stop turtle from drawing even with pen up?

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?

Upvotes: 2

Views: 37088

Answers (7)

Kirshan Murali
Kirshan Murali

Reputation: 173

You should probably try,

turtle.penup()

Upvotes: 0

wjmccann
wjmccann

Reputation: 522

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

Upvotes: 1

ng10
ng10

Reputation: 1910

you called penup without (). with

turtle.penup()

this will work.

Others here said that, but implicitly. trying to ensure it is clear where the typo is.

Upvotes: 0

Naval
Naval

Reputation: 31

import turtle

turtle.up() turtle.goto(0,50) turtle.down()

if you don't put the pen down it will keep on drawing in invisible condition.

Upvotes: 1

user5390283
user5390283

Reputation: 1

no it should be something like this:

turtle.up()         # This a method call
turtle.goto(0,50)   # Part of the method call

Upvotes: -3

Ikke
Ikke

Reputation: 101231

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)

Upvotes: 4

svk
svk

Reputation: 5919

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

import turtle

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

Upvotes: 10

Related Questions