# Author: James Tam # Veersion: November 21, 2022 # Learning objective: # * In the context of the append method knowing exactly what 'level' # (reference, whole list, row, element in a list (at a row/column) # that an instruction refers to. aGrid = [] noRows = int(input("Number rows: ")) noColumns = int(input("Number columns: ")) #Create list for r in range (0,noRows,1): aGrid.append ([]) for c in range (0,noColumns,1): aGrid.append("*") #print(aGrid) #print("type of the list", type(aGrid)) #print("type of the list", type(aGrid[1])) #print("# elements", len(aGrid)) #print("# cols", len(aGrid[0])) #Hard coded 2D list #anotherGrid = [[1,2,3], # [3,2,1]] #print("anotherGrid: type of information for 2nd element (1D list or string)", type(anotherGrid[1])) #print("aGrid: type of information for 2nd element (1D list or string)", type(aGrid[1])) #Display list #for r in range (0,2,1): # for c in range (0,3,1): # print(anotherGrid[r][c], end="") # print() #print("type of the list", type(anotherGrid)) #print("type of the list", type(anotherGrid[1])) #print("# elements", len(anotherGrid)) #print("# cols", len(anotherGrid[0])) #Display list for r in range (0,noRows,1): for c in range (0,noColumns,1): print(aGrid[r][c], end="") print()