<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _ensure_element(tup, elem):
 """ Create a tuple containing all elements of tup, plus elem. Returns the new tuple and the index of elem in the new tuple. """

    try:
        return tup, tup.index(elem)
    except ValueError:
        return tuple(chain(tup, (elem,))), len(tup)