INFO1110 Lecture Notes - Lecture 1: 5,6,7,8, Order Of Merit
Document Summary
For a one-dimensional list, we needed to maintain one index. For a two-dimensional list, we need to maintain two indices (a row index and a column index). two_d_list = [ [7, 8, 9], row = 0 while row < len(two_d_list): col = 0 while col < len(two_d_list[row]): elem = two_d_list[row][col] print(elem, end=", ") col += 1 print() # move to new line row += 1. Here s how to do the same thing with python for loops. two_d_list = [ [7, 8, 9], for row in two_d_list: for elem in row: print(elem, end=", ") print() # move to new line.