logo CodeStepByStep logo


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.

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

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

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.