<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def choose(formatter, value, name, option, format):
 """Adds simple logic to format strings. Example:: u'one' u'other' """

    if not option:
        return
    words = format.split('|')
    num_words = len(words)
    if num_words < 2:
        return
    choices = option.split('|')
    num_choices = len(choices)
    # If the words has 1 more item than the choices, the last word will be
    # used as a default choice.
    if num_words not in (num_choices, num_choices + 1):
        n = num_choices
        raise ValueError('specify %d or %d choices' % (n, n + 1))
    choice = get_choice(value)
    try:
        index = choices.index(choice)
    except ValueError:
        if num_words == num_choices:
            raise ValueError('no default choice supplied')
        index = -1
    return formatter.format(words[index], value)