Its there a more pythonic way, or built in function in python to do the following: def batch(number, batch_size): number_left = number while number_left: if number_left >= batch_size: yield batch_size number_left -= batch_size else: yield number_left number_left = 0 batch(21,10) outputs: [10,10,1] Continue reading...