簡體   English   中英

Python TypeError:'list'對象不能解釋為整數

[英]Python TypeError: 'list' object cannot be interpreted as an integer

我是新來的,所以請耐心TypeError: 'list' object cannot be interpreted as an integer ,我不斷收到錯誤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()

請試試這個:

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()

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM