-1
I need 6 pentagon 5 small ones(inner) and 1 large one(outer), those 6 pentagon's 5 sides should be in 5 different colors我是新的python編程,前幾天我學會了嵌套for循環在python中。我討厭python中的5 x 5 x 5五邊形
的事情是,當我運行我的代碼循環花費如此多的時間停下來,我恨,我想我的程序只畫出5小五邊形有5種不同的顏色和我的代碼是這樣的:
import turtle;
count = 5;
turtle.speed(5);
for steps in range(count) :
for color in ['blue','red','green','pink','yellow'] :
turtle.color(color);
turtle.forward(100);
turtle.right(360/count);
for moreSteps in range(color) :
for color in ['blue','red','green','pink','yellow'] :
turtle.color(color);
turtle.forward(50);
turtle.right(360/count);
turtle.done()
請有人幫助我得到這個謝謝你。
它現在可以工作嗎? – zondo
該代碼無法運行。確保你正確粘貼你的縮進*,以便我們看到。 –
一個問題是'範圍(顏色)'。 'range'函數需要一個整數參數,但'color'是一個字符串,所以這會給出一個錯誤。發佈的代碼中也有一些縮進錯誤。 –