# list_2d_print.py
"""Extra example to demonstrate nested loops for processing
each item in a 2d list (nested list)."""

def print_each_item(list2d):
    """Prints for each row of list2d
        the number of items in that row,
        followed by each item of that row, one on each line.
    Precondition: list2d is a 2d List, possibly ragged, in
    row-major order."""
    n_rows = len(list2d)
    for r in range(n_rows):
        n_cols= len(list2d[r])
        print('Row '+str(r)+' has '+str(n_cols)+' items.')
        for c in range(n_cols):
            print(list2d[r][c])

print('Example 1:  Original 2d list is ')
d= [[10,20],[30,40],[50,60]]
print(d)
print('Print each item on its own line:')
print_each_item(d)

print('\nExample 2:  Original 2d list is ')
d= [['hello', 'world', '!!'],[3,4],[],[5,'six']]
print(d)
print('Print each item on its own line:')
print_each_item(d)
