title: Python code to produce diagonal matrix with 1 above the main diagonal
body: <p>I would like to write a python function that produce a zero matrix of size n by n that has 1 for all the elements above the main diagonal.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>def funtest(n):
      for i in range(0,n-2):
          s = (n,n)
          Y = zeros(s)
          Z = Y
          Z[i,i+1]=1          
  return Z
  </code></pre>
  
  <p>But the result only give 1 in the (n-1, n-2) element of the matrix.</p>
  
  <p>I am stuck and I really think my code is correct and have no clue where is the mistake. And how can I fix it? Can anybody please help?</p>
  
  <p>Thanks.</p>