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

def replace_pool_members(hostname, username, password, name, members):
    '''
    A function to connect to a bigip device and replace members of an existing pool with new members.

    hostname
        The host/address of the bigip device
    username
        The iControl REST username
    password
        The iControl REST password
    name
        The name of the pool to modify
    members
        List of comma delimited pool members to replace existing members with.
        i.e. 10.1.1.1:80,10.1.1.2:80,10.1.1.3:80

    CLI Example::

        salt '*' bigip.replace_pool_members bigip admin admin my-pool 10.2.2.1:80,10.2.2.2:80,10.2.2.3:80
    '''

    payload = {}
    payload['name'] = name
    #specify members if provided
    if members is not None:

        if isinstance(members, six.string_types):
            members = members.split(',')

        pool_members = []
        for member in members:

            #check to see if already a dictionary ( for states)
            if isinstance(member, dict):

                #check for state alternative name 'member_state', replace with state
                if 'member_state' in member.keys():
                    member['state'] = member.pop('member_state')

                #replace underscore with dash
                for key in member:
                    new_key = key.replace('_', '-')
                    member[new_key] = member.pop(key)

                pool_members.append(member)

            #parse string passed via execution command (for executions)
            else:
                pool_members.append({'name': member, 'address': member.split(':')[0]})

        payload['members'] = pool_members

    #build session
    bigip_session = _build_session(username, password)

    #put to REST
    try:
        response = bigip_session.put(
            BIG_IP_URL_BASE.format(host=hostname) + '/ltm/pool/{name}'.format(name=name),
            data=salt.utils.json.dumps(payload)
        )
    except requests.exceptions.ConnectionError as e:
        return _load_connection_error(hostname, e)

    return _load_response(response)