如何使用Python从列表中填写龟坐标?

时间:2013-04-08 14:33:32

标签: python coordinates fill turtle-graphics

我需要知道如何修复此代码,以便在调用名为“redlist”的列表时有一个坐标列表,它会在调用move函数时填充这些点。这就是我到目前为止所做的:

redlist=[]
def move():
        penup()
        if color()[0]=="red":                      
        #coordinates of redlist should be filled here               

def paint():
        pendown()
        if color()[0]=="red":
                begin_fill
                redlist.append(pos())

1 个答案:

答案 0 :(得分:0)

我不知道您的意思是什么,但我称之为xy

redlist=[]
def move():
        penup()
        if color()[0]=="red":                      
            x = 1 # replace this line
            y = 2 # replace this line
            redlist.append((x, y)) # you can access them by #x, y = redlist[-1]
        #coordinates of redlist should be filled here               

def paint():
        pendown()
        if color()[0]=="red":
                begin_fill
                redlist.append(pos())