我有一个乌龟绘制的数字列表,但是我希望钢笔的颜色根据列表中数字的值而改变。在
colors = ["red", "orange", "green", "cyan", "blue", "purple", "magenta", "pink"]
digits = map(int,str(5))
for number in digits:
*code to change pen color to value of "index(number)" (in this case purple)*
t.right(number*10)
以5为例,有没有办法根据列表中元素的值来更改颜色?在
我对Python有点陌生,所以提前感谢您的帮助。在
你可以通过访问海龟的}:
.color
方法来改变它的颜色,如果你只想改变钢笔的颜色,你可以用.pencolor
替换{或者更好的方法是使用
^{pr2}$enumerate
:相关问题 更多 >
编程相关推荐