Does anyone know why the screen isn't popping up? I put the myScreen function above it pops but it isn't working. Is this a problem with my ide?
import turtle
color = input("What color: ")
linewidth = int(input("What linewidth: "))
linelength = int(input("What linelength: "))
shape = input("line, triangle, or square: ")
myTurtle = turtle.Turtle()
myScreen = turtle.Screen()
if shape == "line":
myTurtle.color(color)
myTurtle.width(linewidth)
myTurtle.forward(linelength)
elif shape == "triangle":
myTurtle.color(color)
myTurtle.width(linewidth)
for _ in range(3):
myTurtle.forward(linelength)
myTurtle.left(120)
elif shape == "square":
myTurtle.color(color)
myTurtle.width(linewidth)
for _ in range(4):
myTurtle.forward(linelength)
myTurtle.left(90)
else:
print("Shape not recognized.")
After looking at your code, it turns out that you have not used
turtle.done()in your code. This is the fixed code:This alternative is better than the one suggested in the comments of the post:
turtle.exitonclick(), while it does the job, it also closes the program on a click. turtle.done() is a alias for turtle.mainloop().