Often, I am building an array by iterating through some data, e.g.:
my_array = []
for n in range(1000):
# do operation, get value
my_array.append(value)
# cast to array
my_array = array(my_array)
I find that I have to first build a list and then cast it (using “array”) to an array. Is there a way around these? All these casting calls clutter the code… how can I iteratively build up “my_array”, with it being an array from the start?
If i understand your question correctly, this should do what you want: