I’m getting an error that says None is not iterable. I’m pretty new to python so I might not understand what’s going on. Is it something wrong with the indexing of state? Thanks

if state is not None:
x=np.abs(state[0])**2

y=np.abs(state[1])**2
p1=np.real(x)
p2=np.real(y)
probs=np.array([p1,p2])
# COMPUTE THE MEASUREMENT OUTCOME PROBABILITIES
# RETURN A LIST OF SAMPLE MEASUREMENT OUTCOMES
arr=np.array([0,1])
array=np.random.choice(arr,size=num_meas,replace=True,p=probs)