What are nested lists in Python?
Lists are useful data structures commonly used in Python programming. A nested list is a list of lists, or any list that has another list as an element [a sublist]. They can be helpful if you want to create a matrix or need to store a sublist along with other data types.
Here is how you would create the example nested list above:
Creating a matrix
Creating a matrix is one of the most useful applications of nested lists. This is done by creating a nested list that only has other lists of equal length as elements.
The number of elements in the nested lists is equal to the number of rows of the matrix.
The length of the lists inside the nested list is equal to the number of columns.
Thus, each element of the nested list [matrix] will have two indices: the row and the column.