declare an array in python with size code example
Example 1: python declare array of size n
>>> n = 5
>>> list = [None] * n
>>> print(list)
[None, None, None, None, None]
>>> list.append(1)
>>> list = list[-n:]
>>> print(list)
[None, None, None, None, 1]
>>> list.append(1)
>>> list = list[-n:]
>>> print(list)
[None, None, None, 1, 1]
>>> list.append(1)
>>> list = list[-n:]
>>> print(list)
[None, None, 1, 1, 1]
Example 2: create array with unknown size in python
a = np.array([])
for x in y:
a = np.append(a, x)