List
One, the format of the list: the variable is studentlist = [' Zhangsan ', ' Male ', 29], the element can be of different data types.
Second, print the list: Print the student name print (studentlist[0])
Third, the circular traversal of the list
1. For student in Studentlist:
Print (studentlist)
2, i = 0
length = Len (students)
While I < length:
Print (Studentslist[i])
i + = 1
Iv. increase, deletion, modification and sequencing of the list
1. Add elements: Append, Extend, insert
Append: You can append an element to the end of the list by append.
Extend: By extend you can add elements from another collection to the table one by one.
Insert:insert (Index.object) inserts the element object before the index at the specified position.
2. Modifying elements
When you modify an element, you use the subscript to determine which element is being modified before you can modify it.
3. Find elements: In, not in, index, count
Looking for is to see if the specified element exists.
In: The presence returns TRUE, otherwise false is returned.
Not in: as opposed to in.
Index:a.index (' A ', 1,4) looks for an index and does not exist to report an exception.
Number of Count:a.count (' A ') statistics.
4. Delete elements: Del, pop, remove
Del: Delete del studentlist[0] according to the subscript.
Pop: Deletes the last element Studentlist.pop ().
Remove: Delete studentlist.remove (' name ') based on the value of the element
5. Sorting: Sort, reverse
Sort: The list is rearranged in a specific order, by default, from small to large, and parameter reversetrue can be changed to reverse, from large to small.
Studentlist.reverse () Studentslist.sort (reverse=true)
V. Nesting of lists
An element in a list is another list.
Python Small white Road (list of feature syntax three)