<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def create_snapshot(config='root', snapshot_type='single', pre_number=None,
                    description=None, cleanup_algorithm='number', userdata=None,
                    **kwargs):
    '''
    Creates an snapshot

    config
        Configuration name.
    snapshot_type
        Specifies the type of the new snapshot. Possible values are
        single, pre and post.
    pre_number
        For post snapshots the number of the pre snapshot must be
        provided.
    description
        Description for the snapshot. If not given, the salt job will be used.
    cleanup_algorithm
        Set the cleanup algorithm for the snapshot.

    number
        Deletes old snapshots when a certain number of snapshots
        is reached.
    timeline
        Deletes old snapshots but keeps a number of hourly,
        daily, weekly, monthly and yearly snapshots.
    empty-pre-post
        Deletes pre/post snapshot pairs with empty diffs.
    userdata
        Set userdata for the snapshot (key-value pairs).

    Returns the number of the created snapshot.

    CLI example:

    .. code-block:: bash

        salt '*' snapper.create_snapshot
    '''
    if not userdata:
        userdata = {}

    jid = kwargs.get('__pub_jid')
    if description is None and jid is not None:
        description = 'salt job {0}'.format(jid)

    if jid is not None:
        userdata['salt_jid'] = jid

    new_nr = None
    try:
        if snapshot_type == 'single':
            new_nr = snapper.CreateSingleSnapshot(config, description,
                                                  cleanup_algorithm, userdata)
        elif snapshot_type == 'pre':
            new_nr = snapper.CreatePreSnapshot(config, description,
                                               cleanup_algorithm, userdata)
        elif snapshot_type == 'post':
            if pre_number is None:
                raise CommandExecutionError(
                    "pre snapshot number 'pre_number' needs to be"
                    "specified for snapshots of the 'post' type")
            new_nr = snapper.CreatePostSnapshot(config, pre_number, description,
                                                cleanup_algorithm, userdata)
        else:
            raise CommandExecutionError(
                "Invalid snapshot type '{0}'".format(snapshot_type))
    except dbus.DBusException as exc:
        raise CommandExecutionError(
            'Error encountered while listing changed files: {0}'
            .format(_dbus_exception_to_reason(exc, locals()))
        )
    return new_nr