python create array set 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: intialize array to certain lenght python
>>> lst = [None] * 5
>>> lst
[None, None, None, None, None]