How to make python go through specific part of for loop go first? -


say got list (it has more lists within list, ive included 1 demonstration purposes):

list = [     ['x', ['house a', 'location 4', 'right'],           ['house d', 'location 3', 'left'],           ['house c', 'location 2', 'right']] 

and made function this:

def example(lists):     element in lists:        if element[0] == 'house a':             if element[1] == 'location 4':                 if element[2]  == 'right':                     direction = 0                     house1(loc4, direction)                 elif element[2] == 'left':                     direction = 180                     house1(loc4, direction)     if element[0] == 'x':              graffiti() 

how can make if true after for-loop (i may have not done loop correctly in example correct in proper version of code), draws graffiti(). (doing turtle graphics)

i didn't test code:

direction_map = {'right': 0, 'left': 180} def example(lists):     element in lists:         if element[0] == 'house a' , element[1] == 'location 4':             house1(loc4, direction_map[element[2]])     if list(element element in lists if (element[0] == 'house a'              , element[1] == 'location 4')) , (element[2] in direction_map)):         ....     if element[0] == 'x':          graffiti() 

but understood posted maybe any method looking for.


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 -