010-012 Main contents:
1. The list can have integers, floating-point numbers, strings, objects
General list: love = [' Apple ', ' banana ', ' redhat ', ' CPU ']
Mixed list: Mix = [2, ' Liebiao ', 3.14,[1,2,3]]
Empty list: empty = []
2.append () Adds an element to the tail of the list, adding only one
Example: >>>love.append (' Hello ')
At this time love = [' Apple ', ' banana ', ' redhat ', ' CPU ', ' hello ']
3.extend () extension list, you can add 2 elements to the end, but the parameter can only be one, and it is a list form. The principle is to extend another list with one list
e.g. >>>love.extend ([' Earth ', ' moon ')
At this time love = [' Apple ', ' banana ', ' redhat ', ' CPU ', ' hello ', ' earth ', ' moon ']
4.insert (the position of the list (the first bit is 0), the inserted element)
For example >>>love.insert (1, ' sun ')
At this time love = [' Apple ', ' sun ', ' banana ', ' redhat ', ' CPU ', ' hello ', ' earth ', ' moon ']
5. Replacement of the order of elements in the list (median temp = love[1])
6. Removing elements from a list
Love.remove (' Earth ')
7.del Love[3] The position of the element in parentheses
Del love parentheses followed by list name, list will be deleted
8.love.pop (position ordinal, can be omitted, default delete last) The return value is the deleted element
9. List copy love[1 (if omitted, viewable as 0): 5 (does not include this position; if omitted, always included to the last element)]
10.dir ()
11..count () detects the number of occurrences of elements in parentheses in the list
12..index (element, range) detects the position of the target element
Eg:love.index (cpu,0,7)
Position reversal in 13..reverse () list
14..sort () sort from small to large
. Sort (reverse=true) from big to small
15. The difference between copy love2 = love1 and love2 = love1[:]
Python Learning Notes (iii)------from the Turtle video learning