coordinates = [(1, 0), (-1, 0), (0, 1), (0, -1), (1, 1), (-1, -1), (1, -1), (-1, 1)] for i in range(10): for j in range(10): for x, y in coordinates: di = i + x dj = j + y