Lecture Notes on 26 October 2009 # This function makes an exact copy of a 1-D list def copyList (a): b = [] for item in a: b.append (item) return b # Alternative solution b = [] for i in range (len(a)): b.append(a[i]) return b # This function makes an exact copy of a 2-D list def copyList (a): b = [] for row in a: temp = [] for col in row: temp.append (col) b.append (temp) return b # Alternative solution b = [] for i in range (len(a)): temp = [] for j in range (a[i])): temp.append(a[i][j]) b.append (temp) return b # This function sums the rows of a 2-D list and prints them out def sumRow (a): for row in a: sum = 0 for item in row: sum = sum + item print sum # Alternative solution for i in range (len(a)): sum = 0 for j in range (len(a[i])): sum = sum + a[i][j] print sum