0
我想編寫一個程序,允許用戶從場景的幾個選項中選擇繪製。我抽出太陽來解決問題。當我運行該程序時,太陽不會停止繪圖並填充顏色。其他一切正常。如何修復Python中的無限循環 - 烏龜圖形
import turtle
import random
t = turtle.Turtle()
turtle.setup(800,600)
def draw_sunshine():
t.penup()
t.goto(350,250)
t.pendown()
t.color('black', 'yellow')
t.speed(9)
t.begin_fill()
while True:
t.forward(100)
t.left(170)
t.right(100)
if abs(t.pos()) < 1:
break
t.end_fill()
t.done()
weather = False
while weather == False:
weather = input("Would you like to draw rain or sunshine? ")
if weather == "rain":
draw_rain()
else:
draw_sunshine()