xxxxxxxxxx
mylist = list()
mylist.append(1)
mylist.append(2)
mylist.append(3)
print(mylist)
>>> [1,2,3]
xxxxxxxxxx
theArray = []
theArray.append(0)
print(theArray) # [0]
theArray.append(1)
print(theArray) # [0, 1]
theArray.append(4)
print(theArray) # [0, 1, 4]
xxxxxxxxxx
my_input = ['Engineering', 'Medical']
my_input.append('Science')
print(my_input)
xxxxxxxxxx
capitals = ['A', 'B', 'C']
lowers = ['a', 'b', 'c']
alphabets = capitals + lowers
xxxxxxxxxx
a = [1, 2, 3]
b = [10, 20]
a = a + b # Create a new list a+b and assign back to a.
print a
# [1, 2, 3, 10, 20]
# Equivalently:
a = [1, 2, 3]
b = [10, 20]
a += b
print a
# [1, 2, 3, 10, 20]
xxxxxxxxxx
a = [1, 2, 3]
b = [10, 20]
a.append(b) # Output: [1, 2, 3, [10, 20]]
a.extend(b) # Output: [1, 2, 3, 10, 20]