[Tutor] how can I exit a while loop in turtle graphics
Ian D
duxbuz at hotmail.com
Tue Feb 11 11:18:03 CET 2014
I am trying to exit a while loop whilst using turtle graphics.
I don't seem to have the logic correct at all.
I have tried a few different things
These might seem a bit illogical to you guys but to me they make some sense, sadly
I just don't really grasp these while loops and their usage.(obviously)
I am trying to find a way to use a while loop with the turtle graphics
import turtle as t
import sys
def f():
sys.exit()
while True:
t.fd(1)
t.onkey(f, "Up")
t.listen()
==== another go ====
import turtle as t
import sys
def f():
pass
while True:
t.fd(1)
if t.onkey(f, "Up"):
sys.exit()
t.listen()
==== another go ====
import turtle as t
import sys
def f():
pass
alive = True
while alive:
t.fd(1)
if t.onkey(f, "Up"):
alive = False
t.listen()
More information about the Tutor
mailing list