logo CodeStepByStep logo

list_mystery_2d

Language/Type: Python 2D lists list mystery

Consider the following function:

def mystery2d(a):
    for r in range(len(a)): 
        for c in range(len(a[0]) - 1): 
            if a[r][c + 1] > a[r][c]:
                a[r][c] = a[r][c + 1]

If a two-dimensional list named numbers is initialized to store the following integers, what are its contents after the call shown?

numbers = [[3, 4, 5, 6],
           [4, 5, 6, 7],
           [5, 6, 7, 8]]
mystery2d(numbers)
numbers[0][0]
numbers[0][1]
numbers[0][2]
numbers[0][3]
numbers[1][0]
numbers[1][1]
numbers[1][2]
numbers[1][3]
numbers[2][0]
numbers[2][1]
numbers[2][2]
numbers[2][3]

You must log in before you can solve this problem.

Log In

Need help?

If you do not understand how to solve an exercise or why your solution doesn't work, please contact your TA or instructor.
If something seems wrong with the site (errors, slow performance, incorrect tests, etc.), please

Is there a problem? Contact a site administrator.

©, all rights reserved.