Articles
What you're building
The shopping list is back. But this time each item has a quantity and a price.
A dict instead of a list. More data per entry. Total at checkout.
What you n…
What you're building
A pet shop manager. Each animal has a name, species, price, and availability.
The user can view all animals, search by name, and mark one as sold.
What you…
You've covered dicts from every angle. Here are the mistakes that show up most often — and how to fix them.
1. KeyError — accessing a key that doesn't exist
soldier …
You've covered dicts from every angle. Before moving on, here's everything in one place.
// Creating dicts
{"key": value} # literal
{} # emp…
A dict is just a key and a value. Until you know what to do with it.
get() when you're not sure. update() when data changes. pop() when something's done. items() when you need ev…
The problem...
You have a list of coordinates. Latitude and longitude. Two values that belong together and should never change.
location = [44.4268, 26.1025]
A list works. But …