Learn

``heights = [["Noelle", 61], ["Ali", 70], ["Sam", 67]]``

Two-dimensional lists can be accessed similar to their one-dimensional counterpart. Instead of providing a single pair of brackets `[ ]` we will use an additional set for each dimension past the first.

If we wanted to access `"Noelle"`‘s height:

``````#Access the sublist at index 0, and then access the 1st index of that sublist.
noelles_height = heights
print(noelles_height)``````

Would output:

``61``

Here are the index numbers to access data for the list `heights`:

Element Index
`"Noelle"` `heights`
`61` `heights`
`"Ali"` `heights`
`70` `heights`
`"Sam"` `heights`
`67` `heights`

Let’s practice accessing data in a two-dimensional list.

### Instructions

1.

We want to have a way to store all of our classroom test score data.

Using the provided table, create a two-dimensional list called `class_name_test` to represent the data. Each sublist in `class_name_test` should have one student’s name and their associated score.

Name Test Score
`"Jenny"` `90`
`"Alexus"` `85.5`
`"Sam"` `83`
`"Ellie"` `101.5`

Print `class_name_test` to see the result.

2.

Use double square brackets (`[][]`) to select `Sam`‘s test score from the list `class_name_test`.

Save it to the variable `sams_score`.

Print the variable `sams_score` to see the result.

3.

Use double square brackets (`[][]`) to select `Ellie`s test score from the list `class_name_test`. This time only use negative indices!

Save it to the variable `ellies_score`.

Print the variable `ellies_score` to see the result.