Python: 'int' object is not iterable Random function

1

I'm having this error when I run the code.

If I set pos=(algum numero qualquer) the code runs normally, but if I use this random function of the error.

  

'int' object is not iterable on line 20 at the beginning.

Where am I going wrong? in the Deposit function I am sending y.sub = zeros array.

import numpy as np
import random

def Deposito(x): 

    for i in range(16):
        pos=randint(0,15)
        D=(pos+1)%16;
        E=(pos+15)%16;
        h=0

        while h<30:

            if (x[h,D]==1 and x[h,pos]==0):
                x[h,pos]=1 
                break        
            elif (x[h,E]==1 and x[h,pos]==0):
                x=[h,pos]=1 
                break 
            elif (x[h,pos]==1):
                x[h-1,pos]=1 
                break
            h=h+1
            if h==29:
                x[h,pos]=1


class Amostra: 

    substrato=np.zeros((30,16))
    sub=substrato   

    y=Amostra()
    
asked by anonymous 01.04.2018 / 20:18

1 answer

1

This is not the reason for the error, but here it should be:

pos = random.randint(0,15)

But I think the error is here:

# ...
elif (x[h,E]==1 and x[h,pos]==0):
    x=[h,pos]=1 
    break
# ...

What should be x[h, pos] = 1 , right?

    
01.04.2018 / 21:06