data_sets = [
['O', ['Sheet C', 'Location 2', 'Upright'],
['Sheet B', 'Location 3', 'Upright'],
['Sheet D', 'Location 1', 'Upright'],
['Sheet A', 'Location 4', 'Upright']]
['X', ['Sheet A', 'Location 1', 'Upright'],
['Sheet B', 'Location 2', 'Upright'],
['Sheet C', 'Location 3', 'Upright'],
['Sheet D', 'Location 4', 'Upright']],
]
正しい用紙を正しい場所に貼り付ける必要があります。私の現在のコードは、右の場所に移動することができますが、それだけで(sheet_a_uprightを貼り付けることができます)とない私が欲しいのシートは、例えば、それがこのリストで動作しますが、それは1枚の余分なシートを貼り付け:Python:どのようにして、亀はリストから特定のアクションを実行できますか?
data_sets = [
['O', ['Sheet A', 'Location 1', 'Upright']]
]
コードは正しい場所に貼り付けることができますが、正しいシートを貼り付けません。私が質問の最初に置いた最初の2つのリストのうちの1つをペーストすると、シートAは4つの場所すべてに貼り付けられます。 私のコードは次のとおりです。
def goto_loc(data_sets):
for location in data_sets:
if len(location)>1 and 'Location 1' in location[1]:
goto(-300, 0)
sheet()
elif len(location)>1 and 'Location 2' in location[1]:
goto(-100, 0)
sheet()
elif len(location)>1 and 'Location 3' in location[1]:
goto(100, 0)
sheet()
elif len(location)>1 and 'Location 4' in location[1]:
goto(300, 0)
sheet()
#function for which sheet should be drawn from data_sets
def sheet():
for style in data_sets:
if len(style)>1 and 'Sheet A' in style[1]:
sheet_a_upright()
return True
elif len(style)>1 and 'Sheet B' in style[1]:
sheet_b_upright()
return True
elif len(style)>1 and 'Sheet C' in style[1]:
sheet_c_upright()
return True
elif len(style)>1 and 'Sheet D' in style[1]:
sheet_d_upright()
return True
#define sheet outline and fill
def outline():
pencolor('black')
penup()
forward(100)
pendown()
fillcolor('green')
begin_fill()
left(90)
fd(250)
left(90)
fd(200)
left(90)
fd(500)
left(90)
fd(200)
left(90)
fd(250)
right(90)
penup()
end_fill()
#function for sheet A in upright position
def sheet_a_upright():
outline()
def sheet_b_upright():
outline()
def sheet_c_upright():
outline()
def sheet_c_upright():
outline()
# Paste the sheets onto the billboard as per the provided data set
def paste_up(data_sets):
for each in data_sets:
goto_loc(data_sets)
if sheet():
return
#the number i put into data_sets[] depends on which list i want to paste
paste_up(data_sets[0])
は、どのように私は私のコードは、適切な場所で、右のシートを貼り付けた後、最後に一回の貼り付けを停止するために得ることができます(私はシートのコードが含まれdiddn't?図面が長すぎて重要でないため、アウトライン機能は場所の周りに境界線を描くことです)
アウトラインは意図的なもので、私はシートの描画コードを含んでいませんでした。ちょうど長いタートルの指示です。この問題は、goto_loc()および/またはsheet()定義にあるように見えます。コードはsheet_a_upright()を貼り付けるようにしか見えないからです。 –