Trying to do some some questions in a book yet I'm stuck with my arrays. I get this error:
count[i] = x
TypeError: 'int' object does not support item assignment
My code:
import pylab
count = 0
for i in range (0,6):
x = 180
while x < 300:
count[i] = x
x = x + 20
print count
Basically I need to use a loop to store values which increase until they hit 300 in an array. I'm not sure why I'm getting that error.
I might have worded this poorly. I need to use a loop to make 6 values, from 200, 220, 240... to 300, and store them in an array.
countis an integer, not alist. You need to makecount = [], and to add things to alist, you use.append