Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
NBA Stats Application
The Helper Function
3. Printing player data
Core Functions
Menu Functions
Putting it all together


We'll start with some helper functions that we'll use later when we implement the actual menu options.

We don't want you to manually provide players' statistics for the application, so we have already prepared some data. You can see it in the template code.

def create_players():
  return [
    ('Marcin', 'Gortat', 83, 82, 51.8, 'LA Clippers', ['LKS Lodz', 'RheinEnergie', 'Orlando Magic', 'Anaheim Arsenal', 'Phoenix Suns', 'Washington Wizards']),

The players list contains tuples, each of which contains seven fields and represents a single player. The fields are:

  1. First name
  2. Last name
  3. Height in inches
  4. Number of matches played in the 2017/2018 season
  5. Percentage of field goals in that season
  6. Current club
  7. A nested list with the names of all former clubs.


On line 22, create a function named print_player(player) that accepts a player's tuple and prints all the player's data in the following format:

>> {firstname} {lastname} ({height} in)
>> Matches: {matches}, field goals: {fg}%, current club: {current_club}
>> Former clubs: {former_clubs}

The first line contains eight > signs. The second, third, and fourth lines all start with two > signs, which are followed by one space. Player data should look like this:

>> Marcin Gortat (83 in)
>> Matches: 82, field goals: 51.8%, current club: LA Clippers
>> Former clubs: ['LKS Lodz', 'RheinEnergie', 'Orlando Magic', 'Anaheim Arsenal', 'Phoenix Suns', 'Washington Wizards']

If the player argument is None, print:

No player to show.

Stuck? Here's a hint!

Unpack the tuple with:

firstname, lastname, height, matches, fg, club, former_clubs = player