user6734210 - 11 months ago 77
Python Question

# How to make it so a list is chosen and then an image will be drawn in that location?

I have these 4 lists:

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


and I need to create a function being

def attempt(attempt_number):


so that images that I have created go to these points and start drawing.

So let's say
attempt_01
has been chosen then only the first piece of my image will be drawn.
Due to the large amount of code that has been written I cannot post my image that has been drawn using turtle.

I have tried this code below so that when the first attempt is put in the function, only A will be drawn, but I do not know how to get only A to draw.

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)


It seems that you need something like this:

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)