#-*-coding:utf-8-*-#List" "Learning Objectives: Additions and deletions can be found through the index, or through the slice lookup, the principle of the slice is left including right does not include" "L= ['Hadoop','Hive','R','ETL','python','R']#take the lastPrintL[1:]#take the second to the bottom .PrintL[1:-1]#step is 1, take onePrintL[0:-1:2]#Step 2, right to leftPrintL[3::-2]" "Count: Count the number of times an element has occurred" "PrintL.count ('R')" "in: To see if an element is in the list" "Print 'R' inchL" "Index : Finds the indexes of an element and, if it occurs more than once, adds" "PrintL.index ('R')" "Increase" "L_1= Range (4)PrintL_1l_1.append (8)PrintL_1" "Delete: There are usually three ways to remove, which is remove (), pop (), and Del (), where the most important thing to note is the pop () Delete method, which can be deleted by the index location, and can also return the deleted value, and then often use" "l_2= Range (10)#Delete a specific valueL_2.remove (6)#Delete by index locationL_2.remove (l_2[0])#pop is deleted by index location and can return deleted valuesA = L_2.pop (3)Printa#del Delete directly, delete multipledelL_2[2]#change: Remove the value of the list and assign the value againL_3 = ['I',' Love',' You']#Mandarin RevisionL_3[1] =' Not Love'#Slice ModificationL_3[1:3] = [' Love',' You']PrintL_3#Reverse: Flashback Print ListL_2.reverse ()Printl_2#SortL_4 = [1, 3, 2, 6, 5]l_4.sort ()
Python list, dictionary, string, collection Carbasalate