logo CodeStepByStep logo

reference_mystery_xa

Language/Type: Python parameters reference semantics

When the main function below is called, the following code produces 4 lines of output. Write each line of output below as it would appear on the console.

null
def mystery(x, a):
    x = x + 1
    a[x] = a[x] + 1
    print(x, a)

def main():
    x = 0
    a = [0, 0, 0, 0]
    x = x + 1
    mystery(x, a)
    print(x, a)
    x = x + 1
    mystery(x, a)
    print(x, a)

main()

line 1
line 2
line 3
line 4

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.