Write a function that applies in turn the operators listed in to the . The data is a list of integers. Then is a string of length made up of the characters ’+’ and ’*’ standing respectively for sum and product. The result of the function is to be the outcome of the operations in left-to-right order both of and of : the first operator is applied to the first two integers, the second operator is applied to the outcome and the third integer, and so on.
>>> operate([25, 3], '*') 75 >>> operate([1, 1], '+') 2 >>> operate([2, 3, 4], '*+') 10 >>> operate([2, 3, 4], '+*') 20 >>> operate([333], '') 333 >>> operate([5, 5, 5, 5], '+++') 20 >>> operate([5, 5, 5, 5], '+*+') 55