List, string, Liststring
In List processing of Python, string seems to be a List composed of a single character ....
See the lst4 and lst6 operations in the following code.
Code
# Coding: gb2312
Lst1 = [1, 2, 4]
Lst1.append ([5, 6, 7, 8])
Print lst1 # print the result: [1, 2, 3, 4, [5, 6, 7, 8]
Lst2 = [1, 2, 4]
Lst2.append( "5678 ")
Print lst2 # print the result: [1, 2, 3, 4, '20140901']
Lst3 = [1, 2, 4]
Lst3.extend ([5, 6, 7, 8])
Print lst3 # print the result: [1, 2, 3, 4, 5, 6, 7, 8]
Lst4 = [1, 2, 4]
Lst4.extend ("5678 ")
Print lst4 # print the result: [1, 2, 3, 4, '5', '6', '7', '8']
Lst5 = []
For I in range (10 ):
Lst5 + = [I]
Print lst5 # print the result: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
Lst6 = []
For I in range (10): # print the result: ['A', 'B', 'A', 'B', 'A', 'A', 'B ', 'A', 'B', 'A', 'B', 'A', 'A', 'B', 'B', 'A', 'B ', 'A', 'B', 'A', 'B']
Lst6 + = 'AB'
Print lst6
However, you cannot directly use list + string.
lst1 = []
print lst1
lst2 = lst1 + '123456' #TypeError: can only concatenate list (not "str") to list
print lst2