Lessons
Defining your own functions
Name a block of code with def and run it whenever you need it.
Returning values
Send results back with return, and avoid the print-vs-return trap.
Default and keyword arguments
Make parameters optional and calls readable, and dodge the mutable default trap.
*args and **kwargs
Accept any number of arguments, and spread lists and dicts into calls.
Scope: where variables live
Local vs global variables, UnboundLocalError, and why returning beats global.
Lambdas, docstrings and functions as values
Pass functions around, write one-line lambdas and document your code.
Closures and decorators
Build functions that remember variables, and wrap functions with decorators.
Type hints
Label what goes into and out of a function, and see that Python doesn't check the labels.
Comprehensions & Iteration