Nov-26-2020, 11:12 PM
(Nov-26-2020, 11:03 PM)deanhystad Wrote: A generator that will do thisThank you very much for the answer.
def divbysum(items, step=10): s=1 for i, value in enumerate(items): if i % step == 0: s = sum(items[i:i+step]) yield value/s source = list(range(20)) result = [x for x in divbysum(source, 5)] print(result)
I have a question
Why do we have 5 in this line
result = [x for x in divbysum(source, 5)]