1 #Create a list2list1=['Python', 5,0.2]3list2=['I',' Love']4 5 #access elements by subscript6 Print(list1[0])7 Print(list1[1])8 Print(list2[-1])9 Ten Print(List1[0:2]) One Print(List1[:2]) A Print(list2[:]) - Print(list2[0:]) - the #add element to end of list -List1.append (3.1) - Print(List1) - #inserting elements at I +List2.insert (1,'really') - Print(LIST2) + #deletes the first specified element of the list AList1.remove (3.1) at Print(List1) - #returns the first specified element of the list - Print(List1.index (0.2, )) - #returns the number of occurrences of an element in a list - Print(List1.count (0.2)) - #Add a list to the end of a list in list2.extend (List1) - Print(LIST2) to #Reverse List + List2.reverse () - Print(LIST2) the #list Element Sort *list3=[2,3,1,6,0,9,8,] $ List3.sort ()Panax Notoginseng Print(LIST3) - #Delete the specified element and return it, parameter optional, delete last element without argument theL3=list3.pop (3) + Print(L3) A Print(LIST3)
Python list function description