Lesson 19: Dictionaries: values stored under keys
A dictionary stores values under named keys instead of numbered positions. That makes it the right structure for records — a student, a product, a config file…
Blog
29 lessons, in order — start at lesson 1 and work down.
A dictionary stores values under named keys instead of numbered positions. That makes it the right structure for records — a student, a product, a config file…
A set keeps values with no duplicates and no order. That makes it the fastest way to remove repeats from a list and the natural tool for comparing two groups: what…
A function is a named block of code you can run as often as you like. def creates it, a call runs it, and return sends a value back to whoever called.
A function can be called by position or by name, can have optional arguments, and can accept any number of them. Each style exists to make the call site readable.
Where a variable is created decides where it can be seen. A local variable lives inside its function; a global one lives for the whole program. Mixing them up…
A lambda is a tiny function written in one line, useful as an argument to another function. Python also ships dozens of built-ins — len, sum, sorted, map, filter…