LISTS AND THE APPEND() FUNCTION
Although Python does have an array type (import array), which is essentially a heterogeneous list, the array type has no advantages over the list type other than a slight saving in memory use. You can also define heterogeneous lists:
a = [10, 'hello', [5, '77']]
You can append a new element to an element inside a list:
>>> a = [10, 'hello', [5, '77']]
>>> a[2].append('abc')
>>> a
[10, 'hello', [5, '77', 'abc']]
You can assign simple variables to the elements of a list, as shown here:
myList = [ 'a', 'b', 91.1, (2014, 01, 31) ]
x1, x2, x3, x4 = myList
print('x1:',x1)
print('x2:',x2)
print('x3:',x3)
print('x4:',x4)
The output of the preceding code block is here:
x1: a
x2: b
x3: 91.1
x4: (2014, 1, 31)
The split() function is more convenient (especially when the number of elements is unknown...