November 2018
Beginner
304 pages
7h 35m
English
Lists have only one special method: list.sort(*, key=None, reverse=False). By default, sort() performs an A-Z-style sort, with lower values on the left. Using key allows the use of an additional function to modify the default sort, while reverse performs a Z-A sort. An example of these sorting operations is shown in the following screenshot:

In line 145, a list of strings is created and the default sort is performed in line 146. The results of the default sort are shown in line 147. Note that capital letters come before lowercase ones.
In line 148, the key modifier is used to take lowercase letters into account, ...
Read now
Unlock full access