Pybites Logo

Get the dates ninja belts were earned

Level: Advanced (score: 4)

Another real-world scenario: in this Bite you will parse a json output file with Bites scored at different dates (thanks Mockeroo). Given our ninja ranking you will return a dict of belts earned at (readable) dates.

Complete get_belts below which receives the json file path string. The ninja ranking is wrapped in 2 lists you can use: SCORES and BELTS.

Here is how it should work:

>>> from belts import get_belts
>>> with open('bite_scores1.json') as f:
...     print(f.readlines()[:5])
...
['[{"date":"10/20/2019","score":1},\n', '{"date":"1/19/2019","score":1},\n', '{"date":"8/14/2018","score":1},\n', '{"date":"10/26/2019","score":4},\n', '{"date":"3/27/2019","score":1},\n']
>>> get_belts('bite_scores1.json')
{'white': 'January 23, 2018', 'yellow': 'June 20, 2018', 'orange': 'October 07, 2018', 'green': 'April 08, 2019'}

Have fun and keep calm and code in Python!