Python TypeError:'list'对象不能解释为整数

时间:2016-01-19 21:49:28

标签: python typeerror turtle-graphics

我是新来的,所以忍受我,我不断收到错误TypeError: 'list' object cannot be interpreted as an integer。我不知道如何解决这个错误。任何帮助将不胜感激。

import turtle

wn = turtle.Screen()

bob = turtle.Turtle()
List = ["red", "orange", "yellow", "green", "blue", "violet"]
List2 = [8, 7, 6, 5, 4, 3]
C = (-1)
S = (9)

bob.speed(2)
bob.penup()
bob.left(90)
bob.forward(70)
bob.right(90)
bob.pendown()
def drawAnyShape(Side):
    for i in range(0,Side):
        bob.forward(50)
        bob.right(360/Side)

for i in range(3,9):
    S = (S-1)
    C = (C+1)
    bob.begin_fill()
    bob.color(List[C])
    drawAnyShape([S])
    bob.end_fill()

wn.mainloop()

1 个答案:

答案 0 :(得分:0)

请试试这个:

import turtle

wn = turtle.Screen()

bob = turtle.Turtle()
List = ["red", "orange", "yellow", "green", "blue", "violet"]
List2 = [8, 7, 6, 5, 4, 3]
C = (-1)
S = (9)

bob.speed(2)
bob.penup()
bob.left(90)
bob.forward(70)
bob.right(90)
bob.pendown()
def drawAnyShape(Side):
    for i in range(0,Side):
        bob.forward(50)
        bob.right(360/Side)

for i in range(3,9):
    S = (S-1)
    C = (C+1)
    bob.begin_fill()
    bob.color(List[C])
    drawAnyShape(S)  # <- problem is here!
    bob.end_fill()

wn.mainloop()