- # Practice Problem 5.9
- def add2D(t1, t2):
- '''t1 and t2 are 2D lists with the same number of rows and
- same number of equal sized columns
- add2D increments every item t1[i][j] by t2[i][j]'''
- nrows = len(t1) # number of rows
- ncols = len(t1[0]) # number of columns
- for i in range(nrows): # for every row index i
- for j in range(ncols): # for every column index j
- t1[i][j] += t2[i][j]