logo CodeStepByStep logo

list_mystery2

Language/Type: Python lists

Consider the following function:

def list_mystery2(a):
    for i in range(1, len(a) - 1):
        a[i] = a[i - 1] - a[i] + a[i + 1]

Indicate in the right-hand column what values would be stored in the list after the function list_mystery2 executes if each integer list below is passed as a parameter to it.

a1 = [42, 42] list_mystery2(a1)
a2 = [6, 2, 4] list_mystery2(a2)
a3 = [7, 7, 3, 8, 2] list_mystery2(a3)
a4 = [4, 2, 3, 1, 2, 5] list_mystery2(a4)
a5 = [6, 0, -1, 3, 5, 0, -3] list_mystery2(a5)

You must log in before you can solve this problem.

Log In

Need help?

Stuck on an exercise? Contact your TA or instructor.

If something seems wrong with our site, please

Is there a problem? Contact us.