human
Complete this python program:
def components(arg):
assistant
#Here is the Python program you requested.

    """Converts a dict of components to the format expected by the Google Maps
    server.
    For example:
    c = {"country": "US", "postal_code": "94043"}
    convert.components(c)
    # \country:US|postal_code:94043\
    :param arg: The component filter.
    :type arg: dict
    :rtype: basestring
    """
    def expand(arg):
        for (k, v) in arg.items():
            for item in as_list(v):
                (yield ('%s:%s' % (k, item)))
    if isinstance(arg, dict):
        return '|'.join(sorted(expand(arg)))
    raise TypeError(('Expected    a    dict    for    components,    but    got    %s' % type(arg).__name__))