<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def web2hex(web, force_long=False):
 """Converts WEB representation to HEX :param rgb: web string representation (human readable if possible) :rtype: 3 hex char or 6 hex char string representation WEB representation uses X11 rgb.txt to define conversion between RGB and english color names. Usage ===== '#f00' '#aaa' Traceback (most recent call last):
 AttributeError: '#foo' is not in web format. Need 3 or 6 hex digit. '#aaaaaa' '#aaaaaa' Traceback (most recent call last):
 AttributeError: '#aaaa' is not in web format. Need 3 or 6 hex digit. Traceback (most recent call last):
 ValueError: 'pinky' is not a recognized color. And color names are case insensitive: <Color red> """

    if web.startswith('#'):
        if (LONG_HEX_COLOR.match(web) or
            (not force_long and SHORT_HEX_COLOR.match(web))):
            return web.lower()
        elif SHORT_HEX_COLOR.match(web) and force_long:
            return '#' + ''.join([("%s" % (t, )) * 2 for t in web[1:]])
        raise AttributeError(
            "%r is not in web format. Need 3 or 6 hex digit." % web)

    web = web.lower()
    if web not in COLOR_NAME_TO_RGB:
        raise ValueError("%r is not a recognized color." % web)

    ## convert dec to hex:

    return rgb2hex([float(int(v)) / 255 for v in COLOR_NAME_TO_RGB[web]],
                   force_long)