Articles
The problem...
You have a dict. Data is in there — names, scores, settings, whatever it is.
Now you need to get it out.
There's more than one way to do it. And the wrong …
The problem...
You have a dict. But data changes.
A soldier gets promoted. A score gets updated. An entry needs to be removed.
Dicts in Python aren't frozen — you can cha…
The problem...
You have a dict. But you don't always know what's in it.
Is a specific key there? How many entries does it have? What are all the keys?
You need tools to look in…
The problem...
You have a dict with ten entries. Twenty. A hundred.
You need to do something with every key, every value, or every pair.
Writing it out manually isn't an option…
The problem...
You have three soldiers. Each one has a name, a score, and a status.
You could store them as three separate dicts:
raven = {"score": 85, "active": True}
wolf =…
What you're building
A tip calculator. The user enters the bill amount and rates the service. The program looks up the tip percentage from a dict and calculates how much to leave…