[Python] Why is Python Turtle listen() not working?

Discussão em 'Python' iniciado por Stack, Março 16, 2025.

  1. Stack

    Stack Membro Participativo

    I am very, and by that I mean very new to Python (i know literally nothing). I'm attemtping to create a little game using the turtle module, and following a tutorial I don't see the listen() function working

    here's my code I'm trying to create a controllable character

    from turtle import *

    #background
    Screen().bgcolor("orange")

    #player

    pl = Turtle()
    pl.color('dodgerblue')
    pl.shape('turtle')
    pl.penup()

    def turnleft():
    player.left(30)

    turtle.listen()
    onkeypress(turnleft, "Left")

    speed = 1
    while True:
    pl.forward(speed)

    Continue reading...

Compartilhe esta Página