Here is the task: Generate 20 random integers in the range from -5 to 4, write them to the cells of the array. Count how many positive, negative and zero values are among them. Display array elements and counted quantities. Here is the text of the error:
a [i] = int (a [i]) TypeError: 'int' object is not subscriptable. How to fix this? Thank you very much!
import random a=[] for i in range(20): a=random.randint(-5,4) p=[] n=[] z=[] for i in range(20): a[i]=int(a[i]) for i in range(0,20,1): if(a[i]>0): p.append(a[i]) if(a[i]==0): z.append(a[i]) if (a[i]<0): n.append(a[i]) print('quantity positive',len(p)) print('quantity negative',len(n)) print('quantity zero',len(z))