Read positions in a nested list

In Listing 1, four variables named a, b, c, and d are read from a nested list. The first index selects a row and the second index selects a column.

In row[::-1], the slice [::-1] makes a new list with the items in reverse order. Python’s built-in reversed(row) visits the same items from last to first; list(reversed(row)) also makes a reversed list.

Listing 1: Reading four values from a 3-by-3 nested list (Question 1).
# Each inner list is one row.
matrix = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]

a = matrix[2][0]
b = matrix[0][2]
c = matrix[-1][-2]
d = matrix[1][::-1]

What values do a, b, c, and d contain?

  • a = 3, b = 7, c = 6, and d = [6, 5, 4].
  • a = 7, b = 3, c = 9, and d = [6, 5, 4].
  • a = 7, b = 3, c = 8, and d = [6, 5, 4].
  • a = 7, b = 3, c = 8, and d = [4, 5, 6].