In [1]:
l_empty = []
print(l_empty)
In [2]:
print(len(l_empty))
In [3]:
l_empty.append(100)
l_empty.append(200)
print(l_empty)
In [4]:
l_empty.remove(100)
print(l_empty)
In [5]:
l = [0] * 10
print(l)
In [6]:
print(len(l))
In [7]:
print([0, 1, 2] * 3)
In [8]:
l_2d_ng = [[0] * 4] * 3
print(l_2d_ng)
In [9]:
l_2d_ng[0][0] = 5
print(l_2d_ng)
In [10]:
l_2d_ng[0].append(100)
print(l_2d_ng)
In [11]:
print(id(l_2d_ng[0]) == id(l_2d_ng[1]) == id(l_2d_ng[2]))
In [12]:
l_2d_ok = [[0] * 4 for i in range(3)]
print(l_2d_ok)
In [13]:
l_2d_ok[0][0] = 100
print(l_2d_ok)
In [14]:
print(id(l_2d_ok[0]) == id(l_2d_ok[1]) == id(l_2d_ok[2]))
In [15]:
l_2d_ok_2 = [[0] * 4 for i in [1] * 3]
print(l_2d_ok_2)
In [16]:
l_2d_ok_2[0][0] = 100
print(l_2d_ok_2)
In [17]:
print(id(l_2d_ok_2[0]) == id(l_2d_ok_2[1]) == id(l_2d_ok_2[2]))
In [18]:
l_3d = [[[0] * 2 for i in range(3)] for j in range(4)]
print(l_3d)
In [19]:
l_3d[0][0][0] = 100
print(l_3d)
In [20]:
t = (0,) * 5
print(t)
In [21]:
import array
In [22]:
a = array.array('i', [0] * 5)
print(a)