<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def difference(self, other):
 """ Subtract an Interval or IntervalSet from the intervals in the set. """

        intervals = other if isinstance(other, IntervalSet) else IntervalSet((other,))
        result = IntervalSet()
        for left in self:
            for right in intervals:
                left = left - right
            if isinstance(left, IntervalSet):
                for interval in left:
                    result.add(interval)
            else:
                result.add(left)
        return result