#πŸ”’ whats wrong with this :sob:

41 messages Β· Page 1 of 1 (latest)

feral foxBOT
#

@stoic briar

Python help channel opened

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.

stoic briar
#

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()


serene python
#

there is something wrong with the logic i guess

stoic briar
#

can you plese help

#

😭

lost orchid
#

Is it visualized?

stoic briar
#

wdym visualised

#

it isnt running

lost orchid
#

Like does it show something on the screen

pearl wolf
stoic briar
#

it doesnt even run

serene python
#
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

pearl wolf
stoic briar
stoic briar
#

😭

pearl wolf
#

ctrl+a, delete, then try again without AI

stoic briar
#

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

lost orchid
#

I have no idea what I’m doing

#

Try asking deepai

#

If it doesn’t work, tell it what’s wrong

stoic briar
#

ok

lost orchid
#

Thats how I fixed line 14

shrewd pewter
# stoic briar

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()
feral foxBOT
#
Python help channel closed

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.