title: Get diagonal without using numpy?
body: <p>I'm trying to get the diagonal from a matrix in Python without using <code>numpy</code> (I really can't use it). Does someone here knows how to do it?</p>
  
  <p>Example of what I want to get:</p>
  
  <pre><code>get_diagonal ([[1,2,3,4],[5,6,7,8],[9,10,11,12]], 1, 1, 1)
  Result: [1, 6, 11]
  </code></pre>
  
  <p>Or like:</p>
  
  <pre><code>get_diagonal ([[1,2,3,4],[5,6,7,8],[9,10,11,12]], 1, 2, 1)
  Result: [2, 7, 12]
  </code></pre>
  
  <p>Until know I've tried a lot of stuff but doesn't work.</p>
  
  <pre><code>def obter_diagonal(matrix, line, column, direc):
      d = []
      if direc == 1:
          for i in matrix:
              for j in i:
                  if all(i == line, j == column):
                      d.extend(matrix[i][j])
      else:
          for i in matrix:
              for j in i:
                  d.extend[len(matrix)-1-i][j]
      return d
  </code></pre>
  
  <p>If <code>direc==1</code> I need to get the diagonal that goes from left-> right, top-> bottom.<br />
  If <code>direc==-1</code> need to get the diag that goes from right-> left, top->bottom.</p>