title: Python: Solution for the N-Queen puzzle to check the diagonals
body: <p>Here I have to code the N-Queens problem, where the user will input the dimension of the chessboard and the positions of the Queens.</p>
  
  <pre><code>Enter the dimension of the Chessboard: 4
  Enter position of the Queen: 10
  Enter position of the Queen: 31
  Enter position of the Queen: 02
  Enter position of the Queen: 23
  </code></pre>
  
  <p>And from the user input I have made the candidate solution(which is a list) where the index of the candidate solution represent the column of the Queen and the value represent the row position of the Queen.</p>
  
  <p>The candidate solution is as follows:
      <code>[1, 3, 0, 2]</code></p>
  
  <p>From that I have made a matrix to represent the positions of the Queens:</p>
  
  <pre><code>0, 0, 1, 0
  1, 0, 0, 0
  0, 0, 0, 1
  0, 1, 0, 0
  </code></pre>
  
  <p>My problem is I have to check whether the candidate solution is true, by checking the diagonals and print a message if the solution is true.</p>
  
  <p>Here is my code so far which will print the candidate solution and the matrix showing the positions of the Queens:</p>
  
  <pre><code>#Ask the user to input the dimension of the Chessboard(N)
  N=int(input("Enter the dimension of the Chessboard: "))
  
  #Creating a list of list with zeros in the dimension N*N
  list_0=[0 for m in range(N)]
  
  #Iterating for the length of N
  for t in range(N):
  
      #Creating a list for the input position values
      position=[int(i) for i in input("Enter position of the Queen: ")]
  
      x,y = position[0],position[1]
  
      #The y position is the index of the list_0, where x is the value at the index position
      list_0[y] = x
  
  #Printing the list_0
  print(list_0)
  
  #Creating a list of list with zeros
  list_matrix = [[0 for m in range(len(list_0))] for n in range(len(list_0))]
  
  #Iterating through the list_0 to find the index and the value of the list_0
  for element in range(len(list_0)):
  
      x,y = element, list_0[element]
  
      list_matrix[y][x] = 1
  
  #Defining a list to print the candidate solution for N-Queen problen in matrix format
  def printListInTableFormat(list_default):
  
      #Looping through length of the list_default
      for row in range(len(list_default)):
  
          new_row=''.join(str(list_matrix[row]))
  
          matrix=print(new_row.strip('[]'))
  
      return matrix
  
  #Printing the matrix
  matrix = printListInTableFormat(list_matrix)
  </code></pre>
  
  <p>Since I'm new to Python, any help is much appreciated. Thanks in advance.</p>