Autumn Offers - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
NBA Stats Application
The Helper Function
Core Functions
10. Finding the best player in a club
Menu Functions
Putting it all together

Instruction

Good job! Next, we want to find the best player in a given club by a given parameter.

Exercise

Create a function named find_best_in_club(players, club, user_choice). The function should do the following:

  1. Pick all players from the players list whose current club (the sixth place in each tuple – player[5]) is equal to the club argument.
  2. Return the best player in terms of the tuple element indicated by the user_choice argument.

If there are no players from a given club, simply return None.

Stuck? Here's a hint!

Use the max() function with the optional key argument and the itemgetter function imported from the operator module.

Create a temporary list named club_players. Iterate over all players and use club_player.append() if a given player belongs to a given club.