title: How do I print new line at the end of the for loop in python3 print function?
body: <p>I am trying to print N-queen for every case for given input n. For this I have to write the condition explicitly for j=n-1 to get a new line after every 'n' columns.</p>
  
  <pre><code>for i in range(n):
      for j in range(n):
          if j!=n-1:
              if j==a[i]-1:
                  print('Q',end=' ')
              else:
                  print('-',end=' ')
          else:
              if j==a[i]-1:
                  print('Q')
              else:
                  print('-')  
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>#One case in n=5
  
  - - Q - -
  Q - - - -
  - - - Q -
  - Q - - -
  - - - - Q
  </code></pre>
  
  <p>For not using condition explicitly I get the output in one line, which is obvious.</p>
  
  <pre><code>- - Q - - Q - - - - - - - Q - - Q - - - - - - - Q
  </code></pre>
  
  <p>Is there any way to implicitly write condition in print function in the place of end=' '?</p>
  
  <pre><code>for i in range(n):
      for j in range(n):
          if j==a[i]-1:
              print('Q',(end=' ' if j!=n-1)) #this is not correct
          else:
              print('-',if j!=n-1: end=' ' ) #also not correct
  </code></pre>
  
  <p>I am using IDLE for python 3.4.2.</p>