In a homework set I\'m working on, I\'ve come across the following question, which I am having trouble answering in a Python-3 function:
\"Write a fun
You can use cycle from itertools to alternate +/-
>>> from itertools import cycle >>> data = [*range(1, 5)] >>> sum(i * s for i, s in zip(data, cycle([1, -1]))) -2