First, Sort:
1. Using the method sort () to sort the list permanently
2. Use function sorted () to sort the list temporarily
Note: reverse () does not refer to arranging list elements in the opposite order of alphabetical order, but simply reversing the row of list elements
Column order:
Cars = ['BMW','Audi','Toyota','Subaru']Print(Cars) cars.reverse ()Print(Cars) ['BMW','Audi','Toyota','Subaru']['Subaru','Toyota','Audi','BMW']
Method reverse () permanently modifies the order in which the list elements are arranged, but can revert to the original arrangement at any time, in order to
Just call reverse () again on the list.
Second, determine the length of the list
Use the function Len () to quickly learn the length of the list.
>>> cars = ['bmw'Audi'Toyota ' ' Subaru ' ]>>> len (Cars)4 When you need to do the following tasks, Len () is useful: Determine how many aliens have not been shot, how many visualization data you need to manage, how many registered users the site has, and so on.
Note Python starts at 1 when calculating the number of list elements, so you should not encounter a bad error when determining the length of the list.
Python Learning 2