Improve your Python skills with Exercise 11: .sort() | HolyPython.com (original) (raw)
Python Sort Exercises
Let’s check out some exercises that will help understand Python’s .sort() method better.
Exercise 11-a
Sort the list in ascending order with .sort() method.
.sort() method will modify the actual list and sort it.
Exercise 11-b
This time sort the countries in alphabetic order.
.sort() method will modify the actual list and sort it.
lst.sort(reverse = False)
Exercise 11-c
Now sort the list in descending order with .sort() method.
.sort() method can be used with “reverse =” parameter.
Need More Exercises?
Check out Holy Python AI+ for amazing Python learning tools.
*Includes 14 more programming languages, inspirational tools and 1-on-1 consulting options.
Umut Sagir
Finance & Data Science Professional,
Founder of HolyPython