updating list values of dictionary with the values of another dictionary and printing the result as the values of first dictionary in python -
i have 2 dictionaries :
first 1 legenddict :
legenddict = [ 'standard_animator: blue, 3f7fff, 00bfff, 3fffbf, green, bfff3f, ffbf00, ff7f00, red' , 'extended_animator: lightgray, blue,3f7fff,00bfff,3fffbf,green,bfff3f,ffbf00,ff7f00,red, magenta' ]
and second 1 colordict :
colordict = ['blue' : 'ff00ff', 'red' = '808080', 'lightgray':'d3d3d3','magneta':'00ff00']
i wanna print values of legenddict compared keys of colordict should produce output colors hexadecimal digits
well, first off syntax defining literal dictionaries incorrect. dictionaries surrounded curly brackets this: {}
instead of square brackets this: []
if want 'standard_animator'
, 'extended_animator'
keys lists of colors, want this:
legenddict = {"standard_animator" : ["blue", 3f7fff, 00bfff, 3fffbf, "green", bfff3f, ffbf00, ff7f00, "red"], "extended_animator" : ["lightgray", "blue", 3f7fff, 00bfff, 3fffbf, "green", bfff3f, ffbf00, ff7f00, "red", "magenta"} colordict = {'blue':'ff00ff', 'red':'808080', 'lightgray':'d3d3d3', 'magenta':'00ff00'}
so, print values in legenddict using color names in colordict, can check see if colors keys in colordict, , if so, values:
for color in legenddict['standard_animator']: if color in colordict: print colordict[color] else: print color color in legenddict['extended_animator']: if color in colordict: print colordict[color] else: print color
Comments
Post a Comment