Reputation: 11
When i run the code, the turtle window opens up and then nothing happens. After a few seconds my cursor becomes the loading cursor and I am forced into killing the program. What's wrong with my code here ?
import turtle
import random
turtle.speed(10)
for x in range(1,100):
y=random.randint(000000,999999)
y=str(y)
while not len(y)==0:
y="0"+y
y="#"+y
turtle.color(y)
turtle.circle(40+x)
Upvotes: 0
Views: 80
Reputation: 14893
You had an endless loop in your program
import turtle
import random
turtle.speed(10)
for x in range(1,100):
y=random.randint(000000,999999)
y=str(y)
print(1)
while len(y)<6: # was always true: not len(y)==0
print(3) # would print a lot of 3
y="0"+y
y="#"+y
print(2)
turtle.color(y)
turtle.circle(40+x)
I recommend adding print statements to your program if things like these happen. Then you can track where it hangs. Also using a debugger can help finding out.
Upvotes: 1