python: how can i make my function stop reading through a list once its done what i want -


i need able paste 4 sheets on billboard background using data list, here small segment of list:

data_sets = [ # these 2 initial data sets don't put sheets on billboard # data sets 0 - 1 ['o'], ['x'], # these data sets put sheet in possible locations , orientations # data sets 2 - 9 ['o', ['sheet a', 'location 1', 'upright']], ['o', ['sheet a', 'location 2', 'upright']], ['o', ['sheet a', 'location 3', 'upright']], ['o', ['sheet a', 'location 4', 'upright']], ['o', ['sheet a', 'location 1', 'upside down']], ['o', ['sheet a', 'location 2', 'upside down']], ['o', ['sheet a', 'location 3', 'upside down']], ['o', ['sheet a', 'location 4', 'upside down']] ] 

i'm trying turtle draw sheet once draws it, keeps on going through whole list , drawing outlines, need stop going through list once performs sheet_a_upright(). 'x' , 'o' don't mean @ point, take no notice of them. same thing happening goto_loc() function fixed putting data_sets parameter, when sheet() function, ends not drawing @ all.

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

have sheet function return true if sheet_a_upright() executed.

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()                 elif len(style)>1 , 'sheet c' in style[1]:                     sheet_c_upright()                 elif len(style)>1 , 'sheet d' in style[1]:                     sheet_d_upright() 

then, in paste_up function, check see if sheet() true:

def paste_up(data_sets):             each in data_sets:                 goto_loc(data_sets)                 if sheet():                     return 

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 -