After-school exercises:
1.[] is an empty list
2.
1 ' Hello ') Wrong, should be: spam[2] = ' Hello '
3.[' d '] ' d '
4.[' d '] ' d '
5.[' A ', ' B ']
6.1
7.[3.14, ' cat ', One, ' cat ', True, 99]
8.[3.14, one, ' cat ', True]
9. Connect +, copy *
The 10.inset () method allows you to specify a position insertion
11.del and remove () methods
12.
13. The list can be modified, the meta-ancestors can not modify
14. ((42)) (42,)
15.tuple (); list ()
16. References
17.copy.deepcopy () can copy the list contained in the original variable to copy all lists in the list
Practical projects
4.10.1 Comma Code
1Spam = ['Apples','Bananas','Tofu','Cats','fishes']2 3 4 defLianjie (somelist):5result ="'6 forIinchRange (len (somelist)-1):7Result + = (Somelist[i] +',')8Result + = (' and'+ somelist[-1])9 Print(Result)Ten OneLianjie (spam)
4.10.2-Character metalized grid
1Grid = [['.','.','.','.','.','.'],2['.','0','0','.','.','.'],3['0','0','0','0','.','.'],4['0','0','0','0','0','.'],5['.','0','0','0','0','0'],6['0','0','0','0','0','.'],7['0','0','0','0','.','.'],8['.','0','0','.','.','.'],9['.','.','.','.','.','.']]Ten One forJinchRange (6): A forIinchRange (9): - Print(Grid[i][j], end="')#print each element in a column - Print(Grid[i][j])#finish a column and lay a column
Python Workbooks--4th Chapter list