<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def flip_labels(obj):
 """ Rename fields x to y and y to x Parameters obj : dict_like Object with labels to rename """

    def sub(a, b):
        """
        Substitute all keys that start with a to b
        """
        for label in list(obj.keys()):
            if label.startswith(a):
                new_label = b+label[1:]
                obj[new_label] = obj.pop(label)

    sub('x', 'z')
    sub('y', 'x')
    sub('z', 'y')
    return obj