def replace_at(tup, i, val):
    """Replace a value in a tuple.

    Args:
        tup (tuple): Tuple to replace value in.
        i (int): Index to replace value at.
        val (obj): New value.

    Returns:
        tuple: Tuple with the value replaced.
    """
    listed = list(tup)
    listed[i] = val
    return tuple(listed)
