# 串列

>>> list1 = []
>>> list1.append(1)
>>> list1.append('two')
>>> list1.append(True)
>>> list1
[1, 'two', True]
>>> list1.pop()
True
>>> list1
[1, 'two']
>>> list1.remove('two')
>>> list1
[1]
>>> list1.insert(0, 'three')
>>> list1
['three', 1]
>>> list2 = [1, 'two', True]
>>> list2
[1, 'two', True]

>>> list3 = ['one', 'two', 'three', 'four']
>>> list3[0] = 1
>>> list3
[1, 'two', 'three', 'four']
>>> list3[1:3] = [2, 3]
>>> list3
[1, 2, 3, 'four']
>>> del list3[0]
>>> list3
[2, 3, 'four']
>>> del list3[0:2]
>>> list3
['four']
>>>

>>> list4 = ['one', 'two', 'three', 'four']
>>> len(list4)
4
>>> 'five' in list4
False
>>> for elem in list4:
...     print(elem)
...
one
two
three
four
>>>

>>> list5 = [[1, 2, 3], [4, 5, 6]]
>>> for row in list5:
...     for elem in row:
...         print(elem)
...
1
2
3
4
5
6
>>>

>>> list6 = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
>>> i1 = list6[0:2]
>>> i1
[[1, 2, 3], [4, 5, 6]]
>>> i1[0][1] = 20
>>> i1
[[1, 20, 3], [4, 5, 6]]
>>> list6
[[1, 20, 3], [4, 5, 6], [7, 8, 9]]
>>>

>>> list7 = list6[:]
>>> list7
[[1, 20, 3], [4, 5, 6], [7, 8, 9]]
>>> list7[1][2] = 60
>>> list7
[[1, 20, 3], [4, 5, 60], [7, 8, 9]]
>>> list6
[[1, 20, 3], [4, 5, 60], [7, 8, 9]]
>>>

>>> list8 = [[1, 2, 3], [4, 5, 6]]
>>> list9 = list8 * 2
>>> list9
[[1, 2, 3], [4, 5, 6], [1, 2, 3], [4, 5, 6]]
>>> list9[0][0] = 100
>>> list9
[[100, 2, 3], [4, 5, 6], [100, 2, 3], [4, 5, 6]]
>>> list8
[[100, 2, 3], [4, 5, 6]]
>>>

>>> list10 = [1, 2]
>>> list11 = [3, 4]
>>> list12 = list10 + list11
>>> list12
[1, 2, 3, 4]
>>>

>>> list13 = [6, 1, 7, 3, 8]
>>> list13.sort()
>>> list13
[1, 3, 6, 7, 8]
>>> list13.sort(reverse=True)
>>> list13
[8, 7, 6, 3, 1]
>>>

>>> list14 = ['a', 'w', 'x', 'b']
>>> list14.sort()
>>> list14
['a', 'b', 'w', 'x']
>>> list15 = [1, '3', 5, '2']
>>> list15.sort()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unorderable types: str() < int()
>>>

>>> list('Justin')
['J', 'u', 's', 't', 'i', 'n']
>>>