<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def rgb_to_ansi(color):
 """ Converts hex RGB to the 6x6x6 xterm color space Args: color (str):
 RGB color string in the format "#RRGGBB" Returns: str: ansi color string in the format "ansi_n", where n is between 16 and 230 Reference: https://github.com/chadj2/bash-ui/blob/master/COLORS.md """


        if color[0] != '#' or len(color) != 7:
            return None

        try:
            r = round(int(color[1:3], 16) / 51.0)  # Normalize between 0-5
            g = round(int(color[3:5], 16) / 51.0)
            b = round(int(color[5:7], 16) / 51.0)
            n = int(36 * r + 6 * g + b + 16)
            return 'ansi_{0:d}'.format(n)
        except ValueError:
            return None