当前位置:网站首页>Common methods of listing

Common methods of listing

2021-05-04 10:35:44 The evening wind is stepping on the clouds

increase :

Append( Element value ) Add element at end

Insert( Subscript , value ) Add the element in the specified position

Extend( list ) Appending a list to a list

 

Delete :

   Pop(): The end element is deleted by default

    Parameters are subscripts , Delete by location

    There is a return value , The return value is the deleted content

 

   Remove( Element value ): The element value must exist in the list , Otherwise, the report will be wrong , If the value appears more than once , Delete only the first element that appears

 

   Del List name [ Subscript ]: Delete

   Clear(): clear list

 

modify :

   list 【 The elements to be modified are listed below 】=  New value    Get the data and reassign it

lookup :

  index( Value to find ) Returns the first occurrence of a value in parentheses , No value will report an error

 

Statistics :

  count( Element value ) Counting , Record the number of occurrences in the list for the elements in brackets

How to use statistics to remove duplicate items in the list

 

Sort :

sort(reverse=True)

# Bubble sort Default ascending order ,reverse = Fales
# # When reverse = True  It's in descending order

 

Turn all the elements upside down :

         Reverse()

版权声明
本文为[The evening wind is stepping on the clouds]所创,转载请带上原文链接,感谢
https://chowdera.com/2021/05/20210504103436534s.html