The syntax for using functions of lists

Example description:

List a:


1.append(A)---Add element A to the end of the list, regardless of whether element A already exists in the list, it will still be placed at the end without deduplication


2.insert(0,B)---Add element B at index 0 of the list



3.count(C)---This method will return the number of C elements in the list, that is, how many C elements are in the list


4.remove(D)---This method is used to remove any specified value in the list, that is, remove the D element in the list (if there are multiple D elements in the list, only one will be removed at a time)


5.reverse()--- reverse the entire list (no need to fill in the parameters)

6.extend()--- adds all elements of one list to the end of another list


7.sort()--- sort the elements in the list


8.del a[]--- delete the list element at the specified position (which can also be used to indicate between the index and the index)

For example, del a[0:4] means to delete elements from index 0 to 3 in list a



Queue and stack:

The stack uses this a.pop()

The queue uses this a.pop(0)


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326221754&siteId=291194637