title: Recursive function is not defined inside itself
body: <p>I'm trying to write a program to solve the <a href="https://en.wikipedia.org/wiki/Eight_queens_puzzle" rel="nofollow">N Queens Puzzle</a>. I'm getting the error <code>name 'FindPosition' is not defined</code> when the code tries to call <code>FindPosition(finalArray, startArray)</code> recursively. How do I properly call the function?</p>
  
  <pre><code>class TheQueensAlgoritm():
  
      def FindPosition(finalArray, startArray):
  
          if len(startArray)==0:
              print(finalArray)
              return
          else:
              startIndex = 0
  
              while startIndex &lt;= len(startArray):
                  finalIndex = len(finalArray) - 1
  
                  while finalIndex &gt;= 0:                                                        
                      if (not(startArray[startIndex] == finalArray[finalIndex] - finalIndex + startIndex) and not(startArray[startIndex] == finalArray[finalIndex] + finalIndex - startIndex)):
                          finalIndex = finalIndex - 1                    
                      else:
                          break
                      finalArray.append(startArray[startIndex])
                      startArray.remove(finalArray[-1])
                      FindPosition(finalArray, startArray)
                  startIndex = startIndex + 1
  
              startArray.append(finalArray[-1])
              finalArray.remove(startArray[-1])
              FindPosition(finalArray, startArray)        
  
      startArray = []
      finalArray = []  
      boardSize = input("Type the size of the board = ")
      boardSize = int(boardSize)
  
      for i in range (0, boardSize):
          startArray.append(i) 
  
      finalArray.append(startArray[random.randint(0,boardSize-1)])  
      startArray.remove(finalArray[0])                              
      FindPosition(finalArray, startArray)
  </code></pre>