#NEWLINE# def generate_colormap( colors , palette ) : #NEWLINE# #INDENT# 'Given a list of colors, translate these into indexes into\n\t   the given palette, finding the nearest color where an exact\n\t   match cannot be found.' #NEWLINE# result = [ ] #NEWLINE# for color in colors : #NEWLINE# #INDENT# index = search_palette ( palette , color ) #NEWLINE# result . append ( index ) #NEWLINE# #UNINDENT# return result