title: Python use of class to create and manipulate a grid
body: <p>Still trying to understand how to use class. I have now written the following:</p>
  
  <pre><code>`import random
  class Grid():
      def __init__(self, grid_row, grid_column):
          self.__row = grid_row
          self.__col = grid_column
          self.__board=[]
  
      def make_board(self):
          for row in range(self.__row):
              self.__board.append([])
              for col in range(self.__col):
                  self.__board[row].append('0')
          return self.__board
  
      def change_tile(self):
          choices = (0,1,2)
          x = random.choice(choices)
          y= random.choice(choices)
          self.__board[x][y] = str(2)
  
      def __repr__(self):
          for row in self.__board:
              print( " ".join(row))
  
  
  g = Grid(3,3)
  g.make_board()
  g.change_tile()
  print(g)
  </code></pre>
  
  <p>Firstly when I run this I get a grid printed followed by:</p>
  
  <pre><code>TypeError: __str__ returned non-string (type NoneType)
  </code></pre>
  
  <p>I don't understand why this happens. Second question. If I want to return the self.<strong>board, __str</strong> only returns the last row (0,0,0).With 'print' all three rows and columns are printed. Is there a way around the issue with 'return'?Is it an issue ( apart from the fact that I want to 'see' what I am doing)?
  How would one call Grid(3,3) and get a grid with a randomly placed 2 without having to call each function separately as I have done in my example? Lastly why can I not use the integers 0 or 2, but have to convert everything to a string?. I hope that I have not exceeded the goodwill that exists on this forum by asking so many dumb questions!</p>