{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "f3faed6e",
   "metadata": {},
   "source": [
    "# 13-16 · nonlocal\n",
    "\n",
    "Praktyka do sekcji [„Funkcje zagnieżdżone i nonlocal”](/pl/chapters/rozdzial-13/13-16-vlozhennye-funkcii-nonlocal.html)."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9d63fe8e",
   "metadata": {},
   "source": [
    "## Cel\n",
    "\n",
    "Używać nonlocal, aby funkcja zagnieżdżona zmieniała licznik funkcji nadrzędnej."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a4a6282d",
   "metadata": {},
   "source": [
    "## Podstawowa praktyka zadań ★"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "acfe6344",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-17T18:54:03.155197Z",
     "iopub.status.busy": "2026-08-17T18:54:03.155086Z",
     "iopub.status.idle": "2026-08-17T18:54:03.172763Z",
     "shell.execute_reply": "2026-08-17T18:54:03.172342Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "3\n"
     ]
    }
   ],
   "source": [
    "def outer():\n",
    "    count = 0\n",
    "\n",
    "    def inner():\n",
    "        nonlocal count\n",
    "        count += 1\n",
    "\n",
    "    inner()\n",
    "    inner()\n",
    "    inner()\n",
    "    return count\n",
    "\n",
    "result = outer()\n",
    "print(result)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Cartesian Python 3.14",
   "language": "python",
   "name": "cartesian-python314"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.14.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
