How to stop turtle from drawing even with pen up?

若如初见. 提交于 2019-12-04 19:25:26

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

import turtle

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

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)

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

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.

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.

user5390283

no it should be something like this:

turtle.up()         # This a method call
turtle.goto(0,50)   # Part of the method call
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!