112k views
2 votes
Given a list my_list = [[0, 1, 2), (3,4,5), (6,7,8]]. how would you access the value 7? O a.my_list[2][1] b.my_list[2][2] C. my_list[3][2] d. my_list[3][1]

User Frozenskys
by
8.6k points

1 Answer

1 vote

Hi! To access the value 7 from the given list my_list = [[0, 1, 2], [3, 4, 5], [6, 7, 8]], you would use the following method:

a. my_list[2][1]

Here's the step-by-step explanation:

1. my_list[2] refers to the third sublist, [6, 7, 8], because Python uses zero-based indexing.
2. Within that sublist, my_list[2][1] refers to the second element, which is the value 7.

So, the correct answer is a. my_list[2][1].

User Isaac Lewis
by
6.6k points