triangles=[] squares=[] cubes=[] hexes=[] for x in range(1,1000): triangles.append((x**2+x)/2) for x in range(1,1000): squares.append(x**2) for x in range(1,1000): cubes.append(x**3) for x in range(1000): hexes.append(3*x*x+3*x+1) def diffs(array1,array2): diffs = [] array2_index = 0 array1_index = 0 count = 0 try: while 1: while array1[array1_index] < array2[array2_index]: count = count + 1 array1_index = array1_index+1 diffs.append(count) array2_index = array2_index+1 count = 0 except IndexError: return diffs