#π whats wrong with this :sob:
41 messages Β· Page 1 of 1 (latest)
@stoic briar
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
ok so
im trying to make it so
if i press space
turtle pen
goes up
n if its already up
then move it don
heres my code
pen_down=True
def go_up():
player.sety(player.ycor() + 10)
def go_down():
player.sety(player.ycor() - 10)
def pen():
global pen_down
if pen_down==True:
player.penup()
pen_down=False
else:
player.pendown()
pen_down=True
wn = turtle.Screen
wn.setup(width=1000, height=800)
wn.bgcolor("cyan")
player = turtle.Turtle()
player.shape("turtle")
player.pendown()
player.left(90)
canvas = wn.getcanvas()
wn.listen()
wn.onkey(go_up, "Up")
wn.onkeyrelease(go_up, "Up")
wn.onkeypress(go_down, "Down")
wn.onkey(pen, "space")
turtle.done()
there is something wrong with the logic i guess
Is it visualized?
Like does it show something on the screen
type exit() then try again
it doesnt even run
def pen():
global pen_down
if pen_down==True:
player.penup()
pen_down=False
else:
player.pendown()
pen_down=True
i think something is wrong with that particularly
type this in the terminal there
i mean could be i got the ans from ai
π
most definitely
ctrl+a, delete, then try again without AI
wdym
idk how to make it work without ai
the section you showed me
is the only ai in the whole code
as far as im informed
I have no idea what Iβm doing
Try asking deepai
If it doesnβt work, tell it whatβs wrong
ok
Thats how I fixed line 14
You've got this line:
wn = turle.Screen
That does not call the Screen factory. This would call it: Screen(). But I do not think you should be doing that.
Have you read the turtle docs? https://docs.python.org/3/library/turtle.html
in particular the "Use turtle graphics in a script" section?
It contains this example code:
from turtle import Turtle
from random import random
t = Turtle()
for i in range(100):
steps = int(random() * 100)
angle = int(random() * 360)
t.right(angle)
t.fd(steps)
t.screen.mainloop()
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.