def rescale(data, total=1):
    """
    Rescales numerical values in lists or dictionary values to sum
    to specified total.

    Usage
    *****
    rescale([1, 3]) -> [0.25 0.75]
    rescale({'a': 1, 'b':'9']) -> {'a': 0.1, 'b': 0.9}
    """

    if isinstance(data, list):
        input_total = sum(data)
        assert input_total != 0, 'Error in dogma.rescale(), input_total == 0'

        return [_ / input_total * total for _ in data]

    elif isinstance(data, dict):
        input_total = sum(data.values())
        assert input_total != 0, 'Error in doe.rescale(), input_total == 0'

        return {k: v / input_total * total for k, v in data.items()}
    else:
        return None