In the previous exercise we saved information about famous scientists’ names and birthdays to disk. In this exercise, load that JSON file from disk, extract the months of all the birthdays, and count how many scientists have a birthday in each month.
Your program should output something like:
You already have the skills to achieve this exercise with concepts we’ve already covered: for loops, dictionaries, and basic arithmetic. However, I want to talk about a Python built-in called a
Counter takes a list and counts how many of each element were in the list. To use the Counter, first import it from
This lets you use the
Counter data structure built into Python in your program. Then, give it a list:
print(c), you will see this:
This means there are 3
roast beef, and 2
cheese sandwiches in my list. I can get this information directly from the
Hope this is useful!
Forgot how to submit exercises?