I want a loop to create an array of 11 integers y[i] such that y[i] = (i+1)*(i+2) and it gives me an error which I don't understand.
In [100]: y = zeros(11)
...: for i in range(11):
...: y[i] = (x[i]+1)*(x[i]+2)
...:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-100-7a762b788eff> in <module>()
1 y = zeros(11)
2 for i in range(11):
----> 3 y[i] = (x[i]+1)*(x[i]+2)
4
TypeError: 'int' object has no attribute '__getitem__'
y[i] = (i+1)*(i+2)but your code saysy[i] = (x[i]+1)*(x[i]+2). One of those two must be wrong.