def pad_element(element, wanted_length, pad_value):
    """
    Pads the element with the pad_value so that it the length is equal to wanted_length.
    If element is longer than the wanted_length, then the element will cut to that length.

    :param element: The element that should be padded.
    :type element: str | list
    :param wanted_length: The length that the element should be.
    :type wanted_length: int
    :param pad_value: The value that is used for padding the element.
    :return: The element
    :raises ValueError: If the element is string but the pad_value is not.
    """
    if isinstance(element, str) and not isinstance(pad_value, str):
        raise ValueError("Value needs to be string to concatenate to string element (not {}).".format(type(pad_value)))
    if len(element) < wanted_length:
        if isinstance(element, list):
            element += [pad_value] * (wanted_length - len(element))
        else:
            element += pad_value * (wanted_length - len(element))
    else:
        element = element[:wanted_length]
    return element