List = comma-separated hetereogenous values (items) between square brackets
In [5]:
A = [1, 2, 5, 7, 9]
B = ['Riri', 'Fifi', 'Loulou']
C = ['a', 1, 2, None, True]
In [13]:
print(A[0]); print(A[2]); print(B[:2]); print(B[2:]); print(C[2:4])
Negative indexing and slicing works
In [14]:
print(A[-1]); print(A[:-1]); print(C[2:-1])
In [20]:
A + B
Out[20]:
In [17]:
len(A)
Out[17]:
In [19]:
[A, B]
Out[19]:
In [27]:
A = [1, 2, 3, 4, 5]
A[2:4] = []
print(A)
A[1:2] = [10, 20]
print(A)
In [26]:
B.append('Picsou')
print(B)
Lists are mutable !
In [ ]: