Getting index error in the code in python
<pre><code>def fact(n):
    fac = 1
    while (n&gt;1):
        fac = fac*n
        n -= 1

    return fac

z = 0
t = int(raw_input())
nz = []
for i in range(0,t):
    c = 0
    n = int(raw_input())
    z = fact(n)

    z = list(str(z))
    for j in range(len(z)-1,1,-1):
        if z[j] != '0':
            break
        else:
            c +=1
    nz[i].append(c)
for k in range(0,t):
    print nz[k]
</code></pre>

<p>Hello I am getting </p>

<blockquote>
  <p>Indexerror : index out of range at " nz[i].append(c)</p>
</blockquote>

<p>This program should calculate trailing zeros in the factorial of N.
Can you also please help me optimize my code, so it can run also for large values of N?</p>
