<｜begin▁of▁sentence｜>### Instruction:
Given a sequence ['2', 3.0, 4, '5', 6], where each element is expected to be an integer, how can we convert this sequence to a list of integers, ensuring that all elements are indeed integers, or raise a ValueError if any element doesn't satisfy this condition using the make_list_of_ints function?
### Response:
def make_list_of_ints(sequence):
    """
    Return list of ints from sequence of integral numbers.
    All elements of the sequence must satisfy int(element) == element
    or a ValueError is raised. Sequence is iterated through once.
    If sequence is a list, the non-int values are replaced with ints.
    So, no new list is created.
    """
    if isinstance(sequence, list):
        for i, element in enumerate(sequence):
            if not isinstance(element, int) or int(element) != element:
                raise ValueError(f'Element {element} at index {i} is not an integer')
            sequence[i] = int(element)
        return sequence
    else:
        return [int(element) for element in sequence if int(element) == element]
<|EOT|>
