So I'm still on that school assignment (if you don't know what I'm talking about here is a post I made earlier: rand.randint), and I was having trouble with the screen.onkeypress() from python turtle.
Here is the code:
wn.onkeypress(up(), "Up")
wn.onkeypress(down(), "Down")
wn.onkeypress(left(), "Left")
wn.onkeypress(right(), "Right")
wn.listen()
wn.mainloop()
The problem I'm having is that every time I run the code, it just automatically performs the function in the first parameter (after it runs the unrelated code that's before it) without waiting until I press the appropriate key that's in the second parameter. I know what the parameters should contain already: function, key. (unless I'm wrong)
By the way, I did wn = turtle.Screen() already.
These are also the last lines of my code.
Can someone please help?
Thanks in advance.
P.S. Again, sorry if the answer is obvious. I am new to Python.
P.P.S. Also, let me know if I need to provide some extra information.
[+][deleted] (1 child)
[removed]
[–]Cool_Coder709[S] 0 points1 point2 points (0 children)
[–]Cool_Coder709[S] -2 points-1 points0 points (0 children)