<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def list(gandi, id, vhosts, dates, fqdns, limit):
 """ List hosted certificates. """

    justify = 10
    options = {'items_per_page': limit, 'state': 'created'}

    output_keys = []

    if id:
        output_keys.append('id')

    output_keys.append('subject')

    if dates:
        output_keys.extend(['date_created', 'date_expire'])
        justify = 12

    if fqdns:
        output_keys.append('fqdns')

    if vhosts:
        output_keys.append('vhosts')

    result = gandi.hostedcert.list(options)

    for num, hcert in enumerate(result):
        if num:
            gandi.separator_line()

        if fqdns or vhosts:
            hcert = gandi.hostedcert.info(hcert['id'])

        output_hostedcert(gandi, hcert, output_keys, justify)

    return result