#!/usr/bin/env python3 from copy import deepcopy MAX_V = 9 class Game: def __init__(self): board = [] for x in range(MAX_V): row = [] for y in range(MAX_V): row.append(0) board.append(row) self.board = board def printBoard(self): for x in range(MAX_V): if x%3==0: print() for y in range(MAX_V): if y%3==0: print(" ", end="") print(self.board[x][y], end="") print() print() def setValue(self, x, y, value): if x >= MAX_V or y >= MAX_V: raise OutOfRangeError('Coordinates out of range.') if value > MAX_V: raise OutOfRangeError('Value out of range.') self.board[x][y] = value def getBoard(self): return deepcopy(self.board) if __name__ == "__main__": game = Game() game.printBoard() game.setValue(8,8,9) game.printBoard() print(game.getBoard())