1. Learn
  2. /
  3. Courses
  4. /
  5. Introduction to Python

Connected

Exercise

Multiple arguments

In the previous exercise, you identified optional arguments by viewing the documentation with help(). You'll now apply this to change the behavior of the sorted() function.

Have a look at the documentation of sorted() by typing help(sorted) in the IPython Shell.

You'll see that sorted() takes three arguments: iterable, key, and reverse. In this exercise, you'll only have to specify iterable and reverse, not key.

Two lists have been created for you.

Can you paste them together and sort them in descending order?

Instructions

100 XP
  • Use + to merge the contents of first and second into a new list: full.
  • Call sorted() and on full and specify the reverse argument to be True. Save the sorted list as full_sorted.
  • Finish off by printing out full_sorted.