7. Nested lists
A nested list is a list whose elements are other lists. A matrix is a common example:
Read it with two indexes: the first chooses the row, the second chooses the element inside that row.
You can also assign through both indexes. matrix[1][1] = 10 changes the second element of the second row.
Read a row
Create this matrix:
Print the first row with a single index.
Print exactly:
Create a free account to save your progress and unlock chapter 2.
Read an element inside a row
Create this matrix:
Print the first element of the second row using two indexes.
Print exactly:
Create a free account to save your progress and unlock chapter 2.
Update an element inside a row
Create this matrix:
Change the second element of the third row to 60 using two indexes, then print the whole matrix.
Print exactly:
Create a free account to save your progress and unlock chapter 2.