GH avatar Bite 108. Loop over a dict of namedtuples calculating a total score

In this Bite you calculate the total amount of points earned with Ninja Belts by accessing the given ninja_belts dict.

You learn how to access score and ninjas (= amount of belt owners) from no less than a namedtuple.

Why a namedtuple, you did not even mention a tuple yet?!

Good point, well in our Bites we might actually use them even more so let's get to know them here (if you have a free evening read up on the collections module as well and thank us later).

The function returns the total score int. You learn to write generic code because we test for an updated ninja_belts dict as well, see the TESTS tab.

339 out of 347 users completed this Bite.
Will you be Pythonista #340 to crack this Bite?
It takes an average of ~38 minutes to solve this Bite (submissions 5-240 min).
Pythonistas rate this Bite 4.83 on a 1-10 difficulty scale.
» Up for a challenge? 💪

Login and get coding
We use Python 3.7