Write a function collect_sims(nsim,N,D,p=0.5,nmax=10000) that runs your run_sim function nsim times (with parameters N, D, p) and returns a numpy array of length nmax giving the number of times that the simulation took a specified number of steps to stop. For example, suppose nsim was 8 and successive runs of run_sim gave you 3,4,4,3,6,5,4,4. You would tabulate this as “two 3s, four 4s, one 5, one 6, zero 7s, zero 8s …”
def collect_sims(nsim, N, D, p=0.5, nmax=10000):
    run_sim(N=20, D=6, p=0.5, itmax=5000)
    onecount = 0
    twocount = 0
    threecount = 0
    fourcount = 0
    fivecount = 0
    sixcount = 0
    for k in range (n):
        if D == 1:
            onecount += 1
        if D == 2:
            twocount += 1
        if D == 3:
            threecount += 1
        if D == 4:
            fourcount += 1
        if D == 5:
            fivecount += 1
        if D == 6:
            sixcount += 1
return(k)
print(onecount, "1",twocount,"2",threecount,"3",fourcount,"4",fivecount,"5",sixcount,"6")
It says my 6 variables onecount, twocount, etc are not defined, how can I define them? Also, what can I do to fix my code?
 
     
     
     
    