Q. What is the difference between a regular 2D list and a ragged List?


Answer :-

A regular two dimensional list is a list having lists as its elements and each element-list has the same shape i.e., same number of elements (length).

On the other hand, a list that contains lists with different shapes as its elements is also a 2D list but it is an irregular 2D list, also known as a ragged list.

For instance, in the example code below List1 is a regular 2D list while List2 is a ragged list:

List1 = [[1, 2, 9], [7, 9, 8]]
List2 = [[4, 5, 6], [1, 7]]

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post