<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(self, item, new_item):
 """Replace an item preserving order. Unique([0, 'spam', 2]) Traceback (most recent call last):
 ValueError: 'eggs' is not in list Traceback (most recent call last):
 ValueError: 0 already in list """

        if new_item in self._seen:
            raise ValueError('%r already in list' % new_item)
        idx = self._items.index(item)
        self._seen.remove(item)
        self._seen.add(new_item)
        self._items[idx] = new_item