code: def name_to_hex(name, spec='css3'):
      
      if spec not in SUPPORTED_SPECIFICATIONS:
          raise TypeError("'%s' is not a supported specification for color name lookups; supported specifications are: %s." % (spec,
                                                                                                                               ', '.join(SUPPORTED_SPECIFICATIONS)))
      normalized = name.lower()
      try:
          hex_value = globals()['%s_names_to_hex' % spec][normalized]
      except KeyError:
          raise ValueError("'%s' is not defined as a named color in %s." % (name, spec))
      return hex_value
docs: Convert a color name to a normalized hexadecimal color value.
  
      The optional keyword argument ``spec`` determines which
      specification's list of color names will be used; valid values are
      ``html4``, ``css2``, ``css21`` and ``css3``, and the default is
      ``css3``.
  
      The color name will be normalized to lower-case before being
      looked up, and when no color of that name exists in the given
      specification, ``ValueError`` is raised.
  
      Examples:
  
      >>> name_to_hex('white')
      '#ffffff'
      >>> name_to_hex('navy')
      '#000080'
      >>> name_to_hex('goldenrod')
      '#daa520'
      >>> name_to_hex('goldenrod', spec='html4')
      Traceback (most recent call last):
          ...
      ValueError: 'goldenrod' is not defined as a named color in html4.
      >>> name_to_hex('goldenrod', spec='css5')
      Traceback (most recent call last):
          ...
      TypeError: 'css5' is not a supported specification for color name lookups; supported specifications are: html4, css2, css21, css3.