Roc

Other Roc solutions.
module [colorCode, colors]

colorMap =
    Dict.fromList [
        ("black", 0),
        ("brown", 1),
        ("red", 2),
        ("orange", 3),
        ("yellow", 4),
        ("green", 5),
        ("blue", 6),
        ("violet", 7),
        ("grey", 8),
        ("white", 9),
    ]

colorCode : Str -> Result U64 _
colorCode = \color ->
    Dict.get colorMap color

colors : List Str
colors = Dict.keys colorMap

C

Other C solutions.
#include "resistor_color.h"

resistor_band_t *colors()
{
   static resistor_band_t band[resistor_band_length];
   for (resistor_band_t c = 0; c < resistor_band_length; c += 1)
      band[(int)c] = c;

   return band;
}

int color_code(resistor_band_t c)
{
   return (int)c;
}