我有一个螺旋描记器代码,它可以用给定的参数生成一个形状。当我运行代码时,只有白色和红色起作用,蓝色和绿色只显示为白色
print('Choose a color: ')
print('1. White')
print('2. Blue')
print('3. Green')
print('4. Red')
color1 = input('-')
那部分需要你想要的颜色
if color1 == '1':
color = 'white'
if color1 == '2':
color = 'blue'
if color1 == '3':
color = 'green'
if color1 == '4':
color = 'red'
elif color1 != '1' or '2' or '3' or '4':
color = 'white'
该部分将输入转换为颜色
draw = True
t.speed(0)
num = 0
t.hideturtle()
t.pencolor(color) #this part right here
while draw == True:
t.circle(90)
t.rt(rotate)
num += 1
if num >= lines:
draw = False
print('Press enter to draw again!')
continue
这是绘图循环的一部分,它将海龟的颜色声明为您想要的颜色
您需要修复if/else块:
您还可以使用列表选择颜色:
相关问题 更多 >
编程相关推荐