Functions and scope
- Stage
- 1
- Module
- M1.10
- Lessons
- 1
In this module
- Wrap repeated logic in a function with
def, taking parameters and returning a result. - Tell a local variable from a global one, and use
globalto change a global from inside a function. - Avoid the mutable-default-argument trap, where a default list or dict persists between calls.
- Write a short one-line function with
lambda.
Before this module
Lessons
Practice
Try this on the judge. The link opens the problem on WMOJ.
- 2023 J5CCC Word Hunt (opens on WMOJ in a new tab) WMOJ
Search a small grid for a hidden word along a single horizontal line, the easiest of several scoring tiers.