from typing import List
from typing import Any
from typing import Type


def filter_type(input_list: List[Any], target_type: Type) -> List[Any]:
    """Only keep elements of a given type from a list of elements.

    Traverse a list and return a new list with only elements of the original
    list belonging to a given type.

    Args:
        input_list: input list to filter
        target_type: desired type to keep

    Returns:
        filtered: filtered list
    """
    filtered = [el for el in input_list if type(el) == target_type]

    return filtered