TiffanyWart
New Coder
[CODE lang="python" title="This code works"]import turtle
player=turtle.Turtle()
def space():
print("spacebar pressed")
turtle.onkeypress(space, "space")
turtle.listen()[/CODE]
[CODE lang="python" title="This code doesn't work" highlight="7-8"]import turtle
player=turtle.Turtle()
def space():
print("spacebar pressed")
turtle.onkeypress(space, "space")
turtle.listen()
while True:
a=1[/CODE]
When I have no while loop the code works and everytime i press spacebar it'll print "spacebar pressed"
When I do have a while loop the code doesn't work and the turtle graphics window doesn't respond.
Why doesn't it work when I have the while loop? How can I fix this issue?
player=turtle.Turtle()
def space():
print("spacebar pressed")
turtle.onkeypress(space, "space")
turtle.listen()[/CODE]
[CODE lang="python" title="This code doesn't work" highlight="7-8"]import turtle
player=turtle.Turtle()
def space():
print("spacebar pressed")
turtle.onkeypress(space, "space")
turtle.listen()
while True:
a=1[/CODE]
When I have no while loop the code works and everytime i press spacebar it'll print "spacebar pressed"
When I do have a while loop the code doesn't work and the turtle graphics window doesn't respond.
Why doesn't it work when I have the while loop? How can I fix this issue?