List element zeros after loop for

3

I created a vector and filled it with 100 [0] (because I do not know a better way to do this) and after that I wanted to change those values using a for loop inside another for loop. But what happens is that after the loop inside, when it exits, all values are zeroed again ...

Here's the code (there are three prints out there that you can see that inside for it changes to the value I want but when for ends, it returns to zero):

mediasCa = []

for k in range(0,itera):
    mediasCa.append(0)

for j in range(0,99):
    a = quant
    print(mediasCa[j])
    for i in range(0,itera):
        bola = randint(1,quant)
        if bola < a:
            a -= 1
        else:
            a += 1
    print(mediasCa[i])
    mediasCa[i] = mediasCa[i] + a
    print(mediasCa[i])
    
asked by anonymous 23.10.2015 / 18:13

1 answer

3

The syntax error was missing a TAB .

mediasCa = []    
for k in range(0,itera):
    mediasCa.append(0)
for j in range(0,99):
    aux = []
    a = quant
    for i in range(0,itera):
        bola = randint(1,quant)
        if bola < a:
            a -= 1
        else:
            a += 1
        mediasCa[i] = mediasCa[i] + a
    
23.10.2015 / 18:31