title: Try/Except if function is false
body: <p>I have a function which works out whether or not the file is in a n x n square matrix i.e. 3x3 or 4x4. Now if I call the function it works fine; it says whether or not it is a nxn square.</p>
  
  <p>My problem is I want to use an exception, if the function returns a False value, then it wont load the text file but give a error saying to ensure the file has a nxn grid.
  So for example if I have the grid stored in a text file and I try to load it with python code; the program should keep looping until the file is in the correct format. I wasn't sure if there was an exception for a function boolean</p>
  
  <pre><code>ABC
  DEF
  GHI
  J
  </code></pre>
  
  <p>Currently I have</p>
  
  <pre><code>def grid(n):
      rows = len(n)
      for row in n:
          if len(row) != rows:
              return False   
  </code></pre>
  
  <p>Similar to how the file open works; if it doesn't exist (FileNotFoundError) then it'll keep looping until it finds the input file name</p>