Jun-03-2019, 05:28 AM
colors = [ {'colorkey': 'red', 'status': 'on', 'registered': 'yes'}, {'colorkey': 'blue', 'status': 'off', 'registered': 'no'}, {'colorkey': 'green', 'status': 'on', 'registered': 'yes'}, ] color_to_find = 'red' for element in colors: # element is a dict color = element.get('colorcode') if color == color_to_find: # result found # stop the iteration if you want to have only one result. # otherwise you must walk through the complete list # if you break out of the lopp # you'll only get the first hit break else: pass # result not found, for loop finished completely
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
All humans together. We don't need politicians!