如何选择列表,然后在该位置绘制图像?

时间:2016-08-22 09:01:24

标签: python python-2.7

我有这4个清单:

attempt_01 = [['Piece A', 'In box']] 
attempt_02 = [['Piece B', 'In box']] 
attempt_03 = [['Piece C', 'In box']] 
attempt_04 = [['Piece D', 'In box']] 

我需要创建一个

的函数
def attempt(attempt_number):

以便我创建的图像转到这些点并开始绘图。

所以让我们说attempt_01已被选中,然后只会绘制我的第一张图像。 由于编写了大量代码,我无法发布使用乌龟绘制的图像。

我在下面尝试过这段代码,这样当第一次尝试放入函数时,只会绘制A,但我不知道如何只得到A来绘制。

def draw_attempt(attempt_number):
    if 'Piece A' and 'In box':
        x = 0, 350
    elif 'Piece B' and 'In box':
        y = 0, 350
    elif 'Piece C' and 'In box':
        z = 0, 350
    elif 'Piece D' and 'In box':
        p = 0, 350
    goto(x)
    #STARTS DRAWING FOR IMAGE A(PIECE A CODE IS HERE)
    goto(y)
    #STARTS DRAWING FOR IMAGE A(PIECE B CODE IS HERE)
    goto(z)
    #STARTS DRAWING FOR IMAGE A(PIECE C CODE IS HERE)
    goto(p)
    #STARTS DRAWING FOR IMAGE A(PIECE D CODE IS HERE)

1 个答案:

答案 0 :(得分:0)

看来你需要这样的东西:

def draw_attempt(attempt_number):
    if 'In box':
        x = 0, 350
    elif 'Top_Right':
        x = 350, 350
    elif 'Bottom_Left':
        x = -350, -350
    goto(x)

    if 'Piece A':
        #STARTS DRAWING FOR IMAGE A(PIECE A CODE IS HERE)
    elif 'Piece B':
        #STARTS DRAWING FOR IMAGE B(PIECE B CODE IS HERE)
    elif 'Piece C':
        #STARTS DRAWING FOR IMAGE C(PIECE C CODE IS HERE)