Home  >  Article  >  Backend Development  >  Detailed explanation of functions & methods in Python lists

Detailed explanation of functions & methods in Python lists

小云云
小云云Original
2018-03-30 17:25:432780browse

This article mainly shares with you the detailed explanation of functions & methods in Python lists, hoping to help everyone.

Python list functions & methods

Python contains the following functions:

##Serial numberFunction1cmp(list1, list2)2len( list)3max(list)4min(list)5list(seq)

Python contains the following methods:

Compare the elements of two lists
Number of list elements
Returns the maximum value of list elements
Return the minimum value of the list element
Return the tuple Convert to list
Serial number Method
1 list.append(obj)
In the list Add a new object at the end
2 list.count(obj)
Count the number of times a certain element appears in the list
3 list.extend(seq)
Append multiple values ​​from another sequence at one time to the end of the list (extend the original list with a new list)
4 list.index(obj)
Find the index position of the first matching item of a value from the list
5 list.insert(index, obj)
Insert objects into the list
6 list.pop(obj=list[- 1])
Remove an element in the list (default is the last element) and return the value of the element
7 list.remove(obj )
Remove the first occurrence of a value in the list
8 list.reverse()
Reverse elements in the list
9 list.sort([func])
Sort the original list

Related recommendations:

##Python list List

What you should know about the python list deduplication method

How to reference arrays in Python lists

The above is the detailed content of Detailed explanation of functions & methods in Python lists. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn