python: how can i make turtle perform certain actions from a list? -


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']], ] 

i need able paste correct sheet correct location. current code able go right location can paste sheet_a_upright() , not sheet want example works list, pastes 1 sheet:

data_sets = [     ['o', ['sheet a', 'location 1', 'upright']] ] 

the code can paste correct location doesn't paste right sheet. if make paste 1 of first 2 lists put @ start of question, paste sheet in 4 locations. code follows:

def goto_loc(data_sets):     location in data_sets:         if len(location)>1 , 'location 1' in location[1]:             goto(-300, 0)             sheet()         elif len(location)>1 , 'location 2' in location[1]:             goto(-100, 0)             sheet()         elif len(location)>1 , 'location 3' in location[1]:             goto(100, 0)             sheet()         elif len(location)>1 , 'location 4' in location[1]:             goto(300, 0)             sheet()  #function sheet should drawn data_sets def sheet():     style in data_sets:         if len(style)>1 , 'sheet a' in style[1]:             sheet_a_upright()             return true         elif len(style)>1 , 'sheet b' in style[1]:             sheet_b_upright()             return true         elif len(style)>1 , 'sheet c' in style[1]:             sheet_c_upright()             return true         elif len(style)>1 , 'sheet d' in style[1]:             sheet_d_upright()             return true  #define sheet outline , 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 sheet in upright position def sheet_a_upright():     outline() def sheet_b_upright():     outline() def sheet_c_upright():     outline() def sheet_c_upright():     outline()   # paste sheets onto billboard per provided data set def paste_up(data_sets):     each in data_sets:         goto_loc(data_sets)         if sheet():             return #the number put data_sets[] depends on list want paste paste_up(data_sets[0]) 

how can code paste right sheet in right location , stop pasting once @ end?(i diddn't include code sheet drawing because long , not important, outline function draw border around location)

first, appear have mistyped - sheet_c_upright() defined twice.

second, sheet functions call outline() - intentional? if not, might why same sheet being drawn in locations.


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -