<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def find_nearest_color_index(r, g, b, color_table=None, method='euclid'):
    ''' Given three integers representing R, G, and B,
        return the nearest color index.

        Arguments:
            r:    int - of range 0…255
            g:    int - of range 0…255
            b:    int - of range 0…255

        Returns:
            int, None: index, or None on error.
    '''
    shortest_distance = 257*257*3  # max eucl. distance from #000000 to #ffffff
    index = 0                      # default to black
    if not color_table:
        if not color_table8:
            build_color_tables()
        color_table = color_table8

    for i, values in enumerate(color_table):
        rd = r - values[0]
        gd = g - values[1]
        bd = b - values[2]

        this_distance = (rd * rd) + (gd * gd) + (bd * bd)

        if this_distance < shortest_distance:  # closer
            index = i
            shortest_distance = this_distance

    return index