Source Code:
(back to article)
import array as arr # create an array of integers my_array = arr.array('i', [1, 2, 3, 4, 5]) # change the type of elements in the array to floats my_array.typecode = 'f' # print the updated array print(my_array) # Output: array('f', [1.0, 2.0, 3.0, 4.0, 5.0])
Result:
Report an issue