def colour(word, col, raw):
    """
    Formats `word` in given colour `col` and returns it, unless raw is True.

    Args:
        word(str): Text to format
        col(int): Number corresponding to colour
        raw(bool): False if colour to be added, True otherwise

    Returns:
        Coloured text or unchanged text if raw is True

    """
    if raw:
        return word
    # >>> I have hard coded the char conversion of %27c = \x1b in, as I
    # couldn't find the .format equivalent of %c.
    return '\x1b[{col}m{word}\x1b[0m'.format(col=col, word=word)