Now You Code 1: NBA Stat Leaderboards

Get the current leader of each stat provided by http://www.espn.com/nba/statistics and print the stat title and the list of player in order.

ex:

Offensive Leaders:
Name                              ppg
1. Russell Westbrook, OKC        31.4
2. Anthony Davis, NO              28.6
3. DeMarcus Cousins, SAC          28.5
4. James Harden, HOU              27.9
5. Isaiah Thomas, BOS            27.7

Suggested approach:

  • Use requests to download the page html
  • Use BeautifulSoup to extract the data
  • Create a function to process each stat box.
  • Loop through each stat box and process the stat
  • Use string format functions to format the output

In [ ]: