Autumn Offers - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
NBA Stats Application
The Helper Function
8. Getting a club index
Core Functions
Menu Functions
Putting it all together

Instruction

Great! Now that we have a list of clubs, we can ask a user for a club index.

Exercise

Create a function get_club_index(clubs) that accepts a sorted list of clubs and:

  1. Lists all the clubs' indexes with their names sorted ascending, each in the following format:
    >> {index} {club}
    Here's an example:
    >> 0 LA Clippers
    >> 1 New York Knicks
    
  2. Asks the user to pick a club's index. Use the following prompt:
    >>> Pick club index: 
    
  3. Returns the user's choice as an integer.

Assume that the user always provides a correct index value.

Stuck? Here's a hint!

Because you want to print all clubs' indexes, use the following for loop:

for i in range(len(clubs)):

To get the index from user, use input() function. Remember to convert the result to an integer.