Decorators naturally create closures. nonlocal is useful when a decorator needs to maintain state between calls (like counting retries or caching results).
Challenge
Try modifying the code above to explore different behaviors. Can you extend the example to handle a new use case?