0
0
Pythonprogramming~30 mins

Sorting and reversing lists in Python - Mini Project: Build & Apply

Choose your learning style9 modes available
Sorting and reversing lists
๐Ÿ“‹ What You'll Learn
๐Ÿ’ก Why This Matters
๐ŸŒ Real World
Sorting and reversing lists is useful in many places like organizing names, products, or any data you want to show in order or backwards.
๐Ÿ’ผ Career
Many jobs require sorting data to make it easier to read or analyze, such as in sales reports, customer lists, or inventory management.
Progress0 / 4 steps
1
Create the list of book titles
Create a list called books with these exact titles in this order: 'The Hobbit', '1984', 'Pride and Prejudice', 'To Kill a Mockingbird', 'Moby Dick'.
Python
Need a hint?

Use square brackets [] to create a list and separate items with commas.

2
Sort the list alphabetically
Create a new list called sorted_books that contains the items from books sorted in alphabetical order using the sorted() function.
Python
Need a hint?

The sorted() function returns a new sorted list without changing the original.

3
Reverse the sorted list
Create a new list called reversed_books that contains the items from sorted_books in reverse order using slicing with [::-1].
Python
Need a hint?

Use list[::-1] to reverse a list in Python.

4
Print the sorted and reversed lists
Print the sorted_books list on one line and the reversed_books list on the next line using two separate print() statements.
Python
Need a hint?

Use two print() statements, one for each list.