title: Code is in Infinite Loop and I don't know Why
body: <p>My code is stuck in an infinite loop on the following lines: </p>
  
  <pre><code>   while i &lt;= len(mylist):
          if mylist[i][j] == number:
  </code></pre>
  
  <p>I've stepped through the code but still do not know how to fix it. The problem I'm trying to solve is as follows:</p>
  
  <p>Define a procedure, check_sudoku,
   that takes as input a square list
   of lists representing an n x n
   sudoku puzzle solution and returns the boolean
   True if the input is a valid
   sudoku square and returns the boolean False
   otherwise.</p>
  
  <p>A valid sudoku square satisfies these
   two properties:</p>
  
  <ol>
  <li><p>Each column of the square contains
     each of the whole numbers from 1 to n exactly once.</p></li>
  <li><p>Each row of the square contains each
     of the whole numbers from 1 to n exactly once.</p>
  
  <p>You may assume that the input is square and contains at
  least one row and column.</p></li>
  </ol>
  
  <p>The below code I've written should check for just the row, not the column. Any advice on how to fix it and what I've done wrong would be greatly appreciate, so I'll understand and not make the mistake again. </p>
  
  <pre><code>def check_sudoku(mylist):
      i = 0
      j = 0
      number = len(mylist)
      while i &lt;= len(mylist):
          if mylist[i][j] == number:
              number = number - 1
              j = 0
              if number == 0:
                  i = i + 1
                  number = len(mylist)
              else:
                  j = j + 1
                  if number not in list:
                      break
                      return False
      return True
  
  
  
  check_sudoku([[1, 2, 3, 4],
                [1, 3, 1, 4],
                [3, 1, 2, 3],
                [4, 4, 4, 4]])
  </code></pre>