empty array python 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: python is empty array
if not a:
print("List is empty")
Example 3: python array empty
>>> a = []
>>> not a
True