Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
NBA Stats Application
The Helper Function
Core Functions
Menu Functions
13. Menu option – show sorted players
Putting it all together

Instruction

Good job! Now that we have all helper and core functions, we need to construct the actual program menu, allow the user to choose the desired menu option, accept any necessary user input, and invoke the right core functions.

In other words, we need the additional functions that will coordinate the code we've created so far.

We'll start with a menu option that allows the user to sort all players.

Exercise

Create a function named show_sorted_players(players). The function should do the following:

  1. Ask the user for a parameter, using the get_param_from_user() function you wrote earlier.
  2. Convert the parameter choice into the right tuple index.
  3. Print all players' data, sorted by the given tuple index. Use the sort_players(players, user_param) and print_all_players(players) functions.

Use the functions you've created previously to achieve the above-mentioned actions.

Stuck? Here's a hint!

The parameter you get from the get_param_from_user() function is always "one less" than the actual tuple index you need, so you can use the following:

user_param = get_param_from_user() + 1

This will give you the right tuple element index.