code: def live_neighbours(self, i, j):
          
          s = 0  # The total number of live neighbours.
          # Loop over all the neighbours.
          for x in [i - 1, i, i + 1]:
              for y in [j - 1, j, j + 1]:
                  if (x == i and y == j):
                      continue  # Skip the current point itself - we only want to count the neighbours!
                  if (x != self.N and y != self.N):
                      s += self.old_grid[x][y]
                  # The remaining branches handle the case where the neighbour is off the end of the grid.
                  # In this case, we loop back round such that the grid becomes a "toroidal array".
                  elif (x == self.N and y != self.N):
                      s += self.old_grid[0][y]
                  elif (x != self.N and y == self.N):
                      s += self.old_grid[x][0]
                  else:
                      s += self.old_grid[0][0]
          return s
docs: Count the number of live neighbours around point (i, j).