When I try to assign the array from array.array module as follows:
a = array('f')
a[0] = 2.2
I get array assignment out of range, so basically I have to allocate some dummy values and size in the first statement itself like a = array('f',[0]*20). Is that right?
That happens with
listalso:Basically the
[]syntax requires that the index is valid. It cannot be used to add elements.The
array.arrayclass support mostlistmethods, you can use those to add elements after creation.