SZanlongo
7/28/2016 - 2:40 PM

Add a scalar to all elements in a tuple

Add a scalar to all elements in a tuple

def add_tuple_scalar(a, b):
    """
    Add a scalar to all elements in the tuple
    :param a: tuple
    :param b: scalar
    :return: tuple
        Tuple with all elements incremented by b
    """
    return tuple(i + b for i in a)