title: How to check columns and subgrids (Sudoku Checker in Python)?
body: <p>I'm doing the traditional "Sudoku Puzzle Checker" activity, and I've only been able to figure out how to check the rows so far. As per instruction, I'm suppose to check (in 3 separate functions), the rows, columns, and subgrids (the 3x3 squares) of a solved sudoku puzzle (given in a .csv file). I understand <em>how</em> to do the columns (add 9 each time, 9 times starting numbers ranging from 0-8) and the subgrids (range of 3 numbers, add 6 to get to the next range of 3 numbers e.t.c) but I'm confused as how to implement these concepts into my code. Here's what I have right now:</p>
  
  <pre><code>def load_puzzle(filename):
  
      file = open(filename, 'r')
  
      puzzle = list(file)
  
      #the puzzle currently looks like this:
      ['5,3,4,6,7,8,9,1,2\n', '6,7,2,1,9,5,3,4,8\n', '1,9,8,3,4,2,5,6,7\n', '8,5,9,7,6,1,4,2,3\n', '4,2,6,8,5,3,7,9,1\n', '7,1,3,9,2,4,8,5,6\n', '9,6,1,5,3,7,2,8,4\n', '2,8,7,4,1,9,6,3,5\n', '3,4,5,2,8,6,1,7,9\n']
  
      print_puzzle(puzzle)
  
  
  
  def print_puzzle(puzzle):
  
      print(" ")
  
      count = 0
  
      while count &lt;= 8:
          line = list(puzzle[count])
          line = [x for x in line if x != ',']
          line.remove('\n')
          line.insert(3, '|')
          line.insert(7, '|')
          if count == 3 or count == 6:
              print("---------------------")
          fresh = ' '.join(line)
          count += 1
  
      print('''
  Checking puzzle...
      ''')
  
      delimiter = ','
      together = delimiter.join(puzzle)
      new = list(together)
      new[:] = [x for x in new if x != ',']
      new[:] = [x for x in new if x != '\n']
  
      check_rows(new)
  
      #the puzzle now looks like this:
      ['5', '3', '4', '6', '7', '8', '9', '1', '2', '6', '7', '2', '1', '9', '5', '3', '4', '8', '1', '9', '8', '3', '4', '2', '5', '6', '7', '8', '5', '9', '7', '6', '1', '4', '2', '3', '4', '2', '6', '8', '5', '3', '7', '9', '1', '7', '1', '3', '9', '2', '4', '8', '5', '6', '9', '6', '1', '5', '3', '7', '2', '8', '4', '2', '8', '7', '4', '1', '9', '6', '3', '5', '3', '4', '5', '2', '8', '6', '1', '7', '9']
  
  def check_numbers(numbers):
  
      my_list = ['1', '2', '3', '4', '5', '6', '7', '8', '9']
  
      numbers.sort()
  
      if numbers == my_list:
          return True
      else:
          return False
  
  
  
  def check_rows(n):
  
      count = 0
      start = 0
  
      while count &lt;= 8:
          row = n[start:(start + 9)]
  
          if check_numbers(row) is True:
              count += 1
              start += 9
          elif check_numbers(row) is False:
              break
  
      if count == 9:
          print("Rows okay...")
      else:
          print("Error in row", count)
  
  
      check_columns(n)
  
  
  def check_columns(n):
  
      count = 0
      start = 0
  
      while count &lt;= 8:
          col = n[start::9]
  
          if check_numbers(col) is True:
              count += 1
              start += 1
          elif check_numbers(col) is False:
              break
  
      if count == 9:
          print("Columns okay...")
      else:
          print("Error in row", count)  
  
  def check_subgrids(n):
  
  
  filename = input("Enter file name of solved sudoku puzzle: ")
  
  load_puzzle(filename)
  </code></pre>
  
  <p>I'm looking for a way to find the columns and subgrids similar to how I found the rows (i.e. <code>row = n[start:(start + 9)]</code>) if that's possible. I'm a beginner, so I'm also happy to learn about different tools/ways I could improve my code!</p>
  
  <p>Edit: I've solved my problem with the check_columns function (code updated) but still would appreciate some guidance for the check_subgrid function!</p>