avatar Bite 237. Get the dates Ninja belts were earned

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!

Login and get coding
go back Advanced level
Bitecoin 4X

Will you be Pythonista #60 to crack this Bite?
Resolution time: ~90 min. (avg. submissions of 5-240 min.)
Pythonistas rate this Bite 5.33 on a 1-10 difficulty scale.
» Up for a challenge? 💪

We use Python 3.8